Files
cloud-services/pkg/ota_api/client/operations/get_apicalls_responses.go

503 lines
14 KiB
Go

// Code generated by go-swagger; DO NOT EDIT.
package operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"encoding/json"
"fmt"
"io"
"strconv"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/fiskerinc/cloud-services/pkg/ota_api/models"
)
// GetApicallsReader is a Reader for the GetApicalls structure.
type GetApicallsReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *GetApicallsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewGetApicallsOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
case 400:
result := NewGetApicallsBadRequest()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
case 401:
result := NewGetApicallsUnauthorized()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
case 503:
result := NewGetApicallsServiceUnavailable()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
default:
return nil, runtime.NewAPIError("[GET /apicalls] GetApicalls", response, response.Code())
}
}
// NewGetApicallsOK creates a GetApicallsOK with default headers values
func NewGetApicallsOK() *GetApicallsOK {
return &GetApicallsOK{}
}
/*
GetApicallsOK describes a response with status code 200, with default header values.
OK
*/
type GetApicallsOK struct {
Payload *GetApicallsOKBody
}
// IsSuccess returns true when this get apicalls o k response has a 2xx status code
func (o *GetApicallsOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this get apicalls o k response has a 3xx status code
func (o *GetApicallsOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this get apicalls o k response has a 4xx status code
func (o *GetApicallsOK) IsClientError() bool {
return false
}
// IsServerError returns true when this get apicalls o k response has a 5xx status code
func (o *GetApicallsOK) IsServerError() bool {
return false
}
// IsCode returns true when this get apicalls o k response a status code equal to that given
func (o *GetApicallsOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the get apicalls o k response
func (o *GetApicallsOK) Code() int {
return 200
}
func (o *GetApicallsOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /apicalls][%d] getApicallsOK %s", 200, payload)
}
func (o *GetApicallsOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /apicalls][%d] getApicallsOK %s", 200, payload)
}
func (o *GetApicallsOK) GetPayload() *GetApicallsOKBody {
return o.Payload
}
func (o *GetApicallsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(GetApicallsOKBody)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewGetApicallsBadRequest creates a GetApicallsBadRequest with default headers values
func NewGetApicallsBadRequest() *GetApicallsBadRequest {
return &GetApicallsBadRequest{}
}
/*
GetApicallsBadRequest describes a response with status code 400, with default header values.
Bad request
*/
type GetApicallsBadRequest struct {
Payload *models.CommonJSONError
}
// IsSuccess returns true when this get apicalls bad request response has a 2xx status code
func (o *GetApicallsBadRequest) IsSuccess() bool {
return false
}
// IsRedirect returns true when this get apicalls bad request response has a 3xx status code
func (o *GetApicallsBadRequest) IsRedirect() bool {
return false
}
// IsClientError returns true when this get apicalls bad request response has a 4xx status code
func (o *GetApicallsBadRequest) IsClientError() bool {
return true
}
// IsServerError returns true when this get apicalls bad request response has a 5xx status code
func (o *GetApicallsBadRequest) IsServerError() bool {
return false
}
// IsCode returns true when this get apicalls bad request response a status code equal to that given
func (o *GetApicallsBadRequest) IsCode(code int) bool {
return code == 400
}
// Code gets the status code for the get apicalls bad request response
func (o *GetApicallsBadRequest) Code() int {
return 400
}
func (o *GetApicallsBadRequest) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /apicalls][%d] getApicallsBadRequest %s", 400, payload)
}
func (o *GetApicallsBadRequest) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /apicalls][%d] getApicallsBadRequest %s", 400, payload)
}
func (o *GetApicallsBadRequest) GetPayload() *models.CommonJSONError {
return o.Payload
}
func (o *GetApicallsBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.CommonJSONError)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewGetApicallsUnauthorized creates a GetApicallsUnauthorized with default headers values
func NewGetApicallsUnauthorized() *GetApicallsUnauthorized {
return &GetApicallsUnauthorized{}
}
/*
GetApicallsUnauthorized describes a response with status code 401, with default header values.
Unauthorized
*/
type GetApicallsUnauthorized struct {
Payload *models.CommonJSONError
}
// IsSuccess returns true when this get apicalls unauthorized response has a 2xx status code
func (o *GetApicallsUnauthorized) IsSuccess() bool {
return false
}
// IsRedirect returns true when this get apicalls unauthorized response has a 3xx status code
func (o *GetApicallsUnauthorized) IsRedirect() bool {
return false
}
// IsClientError returns true when this get apicalls unauthorized response has a 4xx status code
func (o *GetApicallsUnauthorized) IsClientError() bool {
return true
}
// IsServerError returns true when this get apicalls unauthorized response has a 5xx status code
func (o *GetApicallsUnauthorized) IsServerError() bool {
return false
}
// IsCode returns true when this get apicalls unauthorized response a status code equal to that given
func (o *GetApicallsUnauthorized) IsCode(code int) bool {
return code == 401
}
// Code gets the status code for the get apicalls unauthorized response
func (o *GetApicallsUnauthorized) Code() int {
return 401
}
func (o *GetApicallsUnauthorized) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /apicalls][%d] getApicallsUnauthorized %s", 401, payload)
}
func (o *GetApicallsUnauthorized) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /apicalls][%d] getApicallsUnauthorized %s", 401, payload)
}
func (o *GetApicallsUnauthorized) GetPayload() *models.CommonJSONError {
return o.Payload
}
func (o *GetApicallsUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.CommonJSONError)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewGetApicallsServiceUnavailable creates a GetApicallsServiceUnavailable with default headers values
func NewGetApicallsServiceUnavailable() *GetApicallsServiceUnavailable {
return &GetApicallsServiceUnavailable{}
}
/*
GetApicallsServiceUnavailable describes a response with status code 503, with default header values.
Service unavailable
*/
type GetApicallsServiceUnavailable struct {
Payload *models.CommonJSONError
}
// IsSuccess returns true when this get apicalls service unavailable response has a 2xx status code
func (o *GetApicallsServiceUnavailable) IsSuccess() bool {
return false
}
// IsRedirect returns true when this get apicalls service unavailable response has a 3xx status code
func (o *GetApicallsServiceUnavailable) IsRedirect() bool {
return false
}
// IsClientError returns true when this get apicalls service unavailable response has a 4xx status code
func (o *GetApicallsServiceUnavailable) IsClientError() bool {
return false
}
// IsServerError returns true when this get apicalls service unavailable response has a 5xx status code
func (o *GetApicallsServiceUnavailable) IsServerError() bool {
return true
}
// IsCode returns true when this get apicalls service unavailable response a status code equal to that given
func (o *GetApicallsServiceUnavailable) IsCode(code int) bool {
return code == 503
}
// Code gets the status code for the get apicalls service unavailable response
func (o *GetApicallsServiceUnavailable) Code() int {
return 503
}
func (o *GetApicallsServiceUnavailable) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /apicalls][%d] getApicallsServiceUnavailable %s", 503, payload)
}
func (o *GetApicallsServiceUnavailable) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /apicalls][%d] getApicallsServiceUnavailable %s", 503, payload)
}
func (o *GetApicallsServiceUnavailable) GetPayload() *models.CommonJSONError {
return o.Payload
}
func (o *GetApicallsServiceUnavailable) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.CommonJSONError)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
/*
GetApicallsOKBody get apicalls o k body
swagger:model GetApicallsOKBody
*/
type GetApicallsOKBody struct {
models.CommonJSONDBQueryResult
// data
Data []*models.CommonAPICall `json:"data"`
}
// UnmarshalJSON unmarshals this object from a JSON structure
func (o *GetApicallsOKBody) UnmarshalJSON(raw []byte) error {
// GetApicallsOKBodyAO0
var getApicallsOKBodyAO0 models.CommonJSONDBQueryResult
if err := swag.ReadJSON(raw, &getApicallsOKBodyAO0); err != nil {
return err
}
o.CommonJSONDBQueryResult = getApicallsOKBodyAO0
// GetApicallsOKBodyAO1
var dataGetApicallsOKBodyAO1 struct {
Data []*models.CommonAPICall `json:"data"`
}
if err := swag.ReadJSON(raw, &dataGetApicallsOKBodyAO1); err != nil {
return err
}
o.Data = dataGetApicallsOKBodyAO1.Data
return nil
}
// MarshalJSON marshals this object to a JSON structure
func (o GetApicallsOKBody) MarshalJSON() ([]byte, error) {
_parts := make([][]byte, 0, 2)
getApicallsOKBodyAO0, err := swag.WriteJSON(o.CommonJSONDBQueryResult)
if err != nil {
return nil, err
}
_parts = append(_parts, getApicallsOKBodyAO0)
var dataGetApicallsOKBodyAO1 struct {
Data []*models.CommonAPICall `json:"data"`
}
dataGetApicallsOKBodyAO1.Data = o.Data
jsonDataGetApicallsOKBodyAO1, errGetApicallsOKBodyAO1 := swag.WriteJSON(dataGetApicallsOKBodyAO1)
if errGetApicallsOKBodyAO1 != nil {
return nil, errGetApicallsOKBodyAO1
}
_parts = append(_parts, jsonDataGetApicallsOKBodyAO1)
return swag.ConcatJSON(_parts...), nil
}
// Validate validates this get apicalls o k body
func (o *GetApicallsOKBody) Validate(formats strfmt.Registry) error {
var res []error
// validation for a type composition with models.CommonJSONDBQueryResult
if err := o.CommonJSONDBQueryResult.Validate(formats); err != nil {
res = append(res, err)
}
if err := o.validateData(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *GetApicallsOKBody) validateData(formats strfmt.Registry) error {
if swag.IsZero(o.Data) { // not required
return nil
}
for i := 0; i < len(o.Data); i++ {
if swag.IsZero(o.Data[i]) { // not required
continue
}
if o.Data[i] != nil {
if err := o.Data[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("getApicallsOK" + "." + "data" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("getApicallsOK" + "." + "data" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// ContextValidate validate this get apicalls o k body based on the context it is used
func (o *GetApicallsOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
// validation for a type composition with models.CommonJSONDBQueryResult
if err := o.CommonJSONDBQueryResult.ContextValidate(ctx, formats); err != nil {
res = append(res, err)
}
if err := o.contextValidateData(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *GetApicallsOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(o.Data); i++ {
if o.Data[i] != nil {
if swag.IsZero(o.Data[i]) { // not required
return nil
}
if err := o.Data[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("getApicallsOK" + "." + "data" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("getApicallsOK" + "." + "data" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// MarshalBinary interface implementation
func (o *GetApicallsOKBody) MarshalBinary() ([]byte, error) {
if o == nil {
return nil, nil
}
return swag.WriteJSON(o)
}
// UnmarshalBinary interface implementation
func (o *GetApicallsOKBody) UnmarshalBinary(b []byte) error {
var res GetApicallsOKBody
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*o = res
return nil
}