// 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 (
	"encoding/json"
	"fmt"
	"io"

	"github.com/go-openapi/runtime"
	"github.com/go-openapi/strfmt"

	"github.com/fiskerinc/cloud-services/pkg/ota_api/models"
)

// GetSubscriptionpackagesReader is a Reader for the GetSubscriptionpackages structure.
type GetSubscriptionpackagesReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *GetSubscriptionpackagesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewGetSubscriptionpackagesOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 400:
		result := NewGetSubscriptionpackagesBadRequest()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 401:
		result := NewGetSubscriptionpackagesUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 503:
		result := NewGetSubscriptionpackagesServiceUnavailable()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[GET /subscriptionpackages] GetSubscriptionpackages", response, response.Code())
	}
}

// NewGetSubscriptionpackagesOK creates a GetSubscriptionpackagesOK with default headers values
func NewGetSubscriptionpackagesOK() *GetSubscriptionpackagesOK {
	return &GetSubscriptionpackagesOK{}
}

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

OK
*/
type GetSubscriptionpackagesOK struct {
	Payload *models.CommonJSONDBQueryResult
}

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

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

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

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

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

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

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

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

func (o *GetSubscriptionpackagesOK) GetPayload() *models.CommonJSONDBQueryResult {
	return o.Payload
}

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

	o.Payload = new(models.CommonJSONDBQueryResult)

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

	return nil
}

// NewGetSubscriptionpackagesBadRequest creates a GetSubscriptionpackagesBadRequest with default headers values
func NewGetSubscriptionpackagesBadRequest() *GetSubscriptionpackagesBadRequest {
	return &GetSubscriptionpackagesBadRequest{}
}

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

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

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

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

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

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

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

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

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

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

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

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

// NewGetSubscriptionpackagesUnauthorized creates a GetSubscriptionpackagesUnauthorized with default headers values
func NewGetSubscriptionpackagesUnauthorized() *GetSubscriptionpackagesUnauthorized {
	return &GetSubscriptionpackagesUnauthorized{}
}

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

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

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

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

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

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

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

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

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

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

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

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

// NewGetSubscriptionpackagesServiceUnavailable creates a GetSubscriptionpackagesServiceUnavailable with default headers values
func NewGetSubscriptionpackagesServiceUnavailable() *GetSubscriptionpackagesServiceUnavailable {
	return &GetSubscriptionpackagesServiceUnavailable{}
}

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

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

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

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

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

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

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

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

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

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

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

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