// 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"

	"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"
)

// GetIssueIDReader is a Reader for the GetIssueID structure.
type GetIssueIDReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *GetIssueIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewGetIssueIDOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 400:
		result := NewGetIssueIDBadRequest()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 401:
		result := NewGetIssueIDUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 503:
		result := NewGetIssueIDServiceUnavailable()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[GET /issue/{id}] GetIssueID", response, response.Code())
	}
}

// NewGetIssueIDOK creates a GetIssueIDOK with default headers values
func NewGetIssueIDOK() *GetIssueIDOK {
	return &GetIssueIDOK{}
}

/*
GetIssueIDOK describes a response with status code 200, with default header values.

OK
*/
type GetIssueIDOK struct {
	Payload *GetIssueIDOKBody
}

// IsSuccess returns true when this get issue Id o k response has a 2xx status code
func (o *GetIssueIDOK) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this get issue Id o k response has a 3xx status code
func (o *GetIssueIDOK) IsRedirect() bool {
	return false
}

// IsClientError returns true when this get issue Id o k response has a 4xx status code
func (o *GetIssueIDOK) IsClientError() bool {
	return false
}

// IsServerError returns true when this get issue Id o k response has a 5xx status code
func (o *GetIssueIDOK) IsServerError() bool {
	return false
}

// IsCode returns true when this get issue Id o k response a status code equal to that given
func (o *GetIssueIDOK) IsCode(code int) bool {
	return code == 200
}

// Code gets the status code for the get issue Id o k response
func (o *GetIssueIDOK) Code() int {
	return 200
}

func (o *GetIssueIDOK) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /issue/{id}][%d] getIssueIdOK %s", 200, payload)
}

func (o *GetIssueIDOK) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /issue/{id}][%d] getIssueIdOK %s", 200, payload)
}

func (o *GetIssueIDOK) GetPayload() *GetIssueIDOKBody {
	return o.Payload
}

func (o *GetIssueIDOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {

	o.Payload = new(GetIssueIDOKBody)

	// response payload
	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
		return err
	}

	return nil
}

// NewGetIssueIDBadRequest creates a GetIssueIDBadRequest with default headers values
func NewGetIssueIDBadRequest() *GetIssueIDBadRequest {
	return &GetIssueIDBadRequest{}
}

/*
GetIssueIDBadRequest describes a response with status code 400, with default header values.

Bad request
*/
type GetIssueIDBadRequest struct {
	Payload *models.CommonJSONError
}

// IsSuccess returns true when this get issue Id bad request response has a 2xx status code
func (o *GetIssueIDBadRequest) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this get issue Id bad request response has a 3xx status code
func (o *GetIssueIDBadRequest) IsRedirect() bool {
	return false
}

// IsClientError returns true when this get issue Id bad request response has a 4xx status code
func (o *GetIssueIDBadRequest) IsClientError() bool {
	return true
}

// IsServerError returns true when this get issue Id bad request response has a 5xx status code
func (o *GetIssueIDBadRequest) IsServerError() bool {
	return false
}

// IsCode returns true when this get issue Id bad request response a status code equal to that given
func (o *GetIssueIDBadRequest) IsCode(code int) bool {
	return code == 400
}

// Code gets the status code for the get issue Id bad request response
func (o *GetIssueIDBadRequest) Code() int {
	return 400
}

func (o *GetIssueIDBadRequest) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /issue/{id}][%d] getIssueIdBadRequest %s", 400, payload)
}

func (o *GetIssueIDBadRequest) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /issue/{id}][%d] getIssueIdBadRequest %s", 400, payload)
}

func (o *GetIssueIDBadRequest) GetPayload() *models.CommonJSONError {
	return o.Payload
}

func (o *GetIssueIDBadRequest) 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
}

// NewGetIssueIDUnauthorized creates a GetIssueIDUnauthorized with default headers values
func NewGetIssueIDUnauthorized() *GetIssueIDUnauthorized {
	return &GetIssueIDUnauthorized{}
}

/*
GetIssueIDUnauthorized describes a response with status code 401, with default header values.

Unauthorized
*/
type GetIssueIDUnauthorized struct {
	Payload *models.CommonJSONError
}

// IsSuccess returns true when this get issue Id unauthorized response has a 2xx status code
func (o *GetIssueIDUnauthorized) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this get issue Id unauthorized response has a 3xx status code
func (o *GetIssueIDUnauthorized) IsRedirect() bool {
	return false
}

// IsClientError returns true when this get issue Id unauthorized response has a 4xx status code
func (o *GetIssueIDUnauthorized) IsClientError() bool {
	return true
}

// IsServerError returns true when this get issue Id unauthorized response has a 5xx status code
func (o *GetIssueIDUnauthorized) IsServerError() bool {
	return false
}

// IsCode returns true when this get issue Id unauthorized response a status code equal to that given
func (o *GetIssueIDUnauthorized) IsCode(code int) bool {
	return code == 401
}

// Code gets the status code for the get issue Id unauthorized response
func (o *GetIssueIDUnauthorized) Code() int {
	return 401
}

func (o *GetIssueIDUnauthorized) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /issue/{id}][%d] getIssueIdUnauthorized %s", 401, payload)
}

func (o *GetIssueIDUnauthorized) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /issue/{id}][%d] getIssueIdUnauthorized %s", 401, payload)
}

func (o *GetIssueIDUnauthorized) GetPayload() *models.CommonJSONError {
	return o.Payload
}

func (o *GetIssueIDUnauthorized) 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
}

// NewGetIssueIDServiceUnavailable creates a GetIssueIDServiceUnavailable with default headers values
func NewGetIssueIDServiceUnavailable() *GetIssueIDServiceUnavailable {
	return &GetIssueIDServiceUnavailable{}
}

/*
GetIssueIDServiceUnavailable describes a response with status code 503, with default header values.

Service unavailable
*/
type GetIssueIDServiceUnavailable struct {
	Payload *models.CommonJSONError
}

// IsSuccess returns true when this get issue Id service unavailable response has a 2xx status code
func (o *GetIssueIDServiceUnavailable) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this get issue Id service unavailable response has a 3xx status code
func (o *GetIssueIDServiceUnavailable) IsRedirect() bool {
	return false
}

// IsClientError returns true when this get issue Id service unavailable response has a 4xx status code
func (o *GetIssueIDServiceUnavailable) IsClientError() bool {
	return false
}

// IsServerError returns true when this get issue Id service unavailable response has a 5xx status code
func (o *GetIssueIDServiceUnavailable) IsServerError() bool {
	return true
}

// IsCode returns true when this get issue Id service unavailable response a status code equal to that given
func (o *GetIssueIDServiceUnavailable) IsCode(code int) bool {
	return code == 503
}

// Code gets the status code for the get issue Id service unavailable response
func (o *GetIssueIDServiceUnavailable) Code() int {
	return 503
}

func (o *GetIssueIDServiceUnavailable) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /issue/{id}][%d] getIssueIdServiceUnavailable %s", 503, payload)
}

func (o *GetIssueIDServiceUnavailable) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /issue/{id}][%d] getIssueIdServiceUnavailable %s", 503, payload)
}

func (o *GetIssueIDServiceUnavailable) GetPayload() *models.CommonJSONError {
	return o.Payload
}

func (o *GetIssueIDServiceUnavailable) 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
}

/*
GetIssueIDOKBody get issue ID o k body
swagger:model GetIssueIDOKBody
*/
type GetIssueIDOKBody struct {
	models.CommonJSONDBQueryResult

	// data
	Data *models.CommonIssue `json:"data,omitempty"`
}

// UnmarshalJSON unmarshals this object from a JSON structure
func (o *GetIssueIDOKBody) UnmarshalJSON(raw []byte) error {
	// GetIssueIDOKBodyAO0
	var getIssueIDOKBodyAO0 models.CommonJSONDBQueryResult
	if err := swag.ReadJSON(raw, &getIssueIDOKBodyAO0); err != nil {
		return err
	}
	o.CommonJSONDBQueryResult = getIssueIDOKBodyAO0

	// GetIssueIDOKBodyAO1
	var dataGetIssueIDOKBodyAO1 struct {
		Data *models.CommonIssue `json:"data,omitempty"`
	}
	if err := swag.ReadJSON(raw, &dataGetIssueIDOKBodyAO1); err != nil {
		return err
	}

	o.Data = dataGetIssueIDOKBodyAO1.Data

	return nil
}

// MarshalJSON marshals this object to a JSON structure
func (o GetIssueIDOKBody) MarshalJSON() ([]byte, error) {
	_parts := make([][]byte, 0, 2)

	getIssueIDOKBodyAO0, err := swag.WriteJSON(o.CommonJSONDBQueryResult)
	if err != nil {
		return nil, err
	}
	_parts = append(_parts, getIssueIDOKBodyAO0)
	var dataGetIssueIDOKBodyAO1 struct {
		Data *models.CommonIssue `json:"data,omitempty"`
	}

	dataGetIssueIDOKBodyAO1.Data = o.Data

	jsonDataGetIssueIDOKBodyAO1, errGetIssueIDOKBodyAO1 := swag.WriteJSON(dataGetIssueIDOKBodyAO1)
	if errGetIssueIDOKBodyAO1 != nil {
		return nil, errGetIssueIDOKBodyAO1
	}
	_parts = append(_parts, jsonDataGetIssueIDOKBodyAO1)
	return swag.ConcatJSON(_parts...), nil
}

// Validate validates this get issue ID o k body
func (o *GetIssueIDOKBody) 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 *GetIssueIDOKBody) validateData(formats strfmt.Registry) error {

	if swag.IsZero(o.Data) { // not required
		return nil
	}

	if o.Data != nil {
		if err := o.Data.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("getIssueIdOK" + "." + "data")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("getIssueIdOK" + "." + "data")
			}
			return err
		}
	}

	return nil
}

// ContextValidate validate this get issue ID o k body based on the context it is used
func (o *GetIssueIDOKBody) 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 *GetIssueIDOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error {

	if o.Data != nil {

		if swag.IsZero(o.Data) { // not required
			return nil
		}

		if err := o.Data.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("getIssueIdOK" + "." + "data")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("getIssueIdOK" + "." + "data")
			}
			return err
		}
	}

	return nil
}

// MarshalBinary interface implementation
func (o *GetIssueIDOKBody) MarshalBinary() ([]byte, error) {
	if o == nil {
		return nil, nil
	}
	return swag.WriteJSON(o)
}

// UnmarshalBinary interface implementation
func (o *GetIssueIDOKBody) UnmarshalBinary(b []byte) error {
	var res GetIssueIDOKBody
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*o = res
	return nil
}
