package operations

import (
	"fmt"
	"io"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/runtime"
	"github.com/go-openapi/swag"

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

	models "github.com/sajayantony/acrctl/models"
)

type GetAcrV1NameManifestsReferenceMetadataMetadataReader struct {
	formats strfmt.Registry
}

func (o *GetAcrV1NameManifestsReferenceMetadataMetadataReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {

	case 200:
		result := NewGetAcrV1NameManifestsReferenceMetadataMetadataOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil

	case 400:
		result := NewGetAcrV1NameManifestsReferenceMetadataMetadataBadRequest()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result

	case 401:
		result := NewGetAcrV1NameManifestsReferenceMetadataMetadataUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result

	case 404:
		result := NewGetAcrV1NameManifestsReferenceMetadataMetadataNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result

	default:
		return nil, runtime.NewAPIError("unknown error", response, response.Code())
	}
}

func NewGetAcrV1NameManifestsReferenceMetadataMetadataOK() *GetAcrV1NameManifestsReferenceMetadataMetadataOK {
	return &GetAcrV1NameManifestsReferenceMetadataMetadataOK{}
}

type GetAcrV1NameManifestsReferenceMetadataMetadataOK struct {
	Payload string
}

func (o *GetAcrV1NameManifestsReferenceMetadataMetadataOK) Error() string {
	return fmt.Sprintf("[GET /acr/v1/{name}/_manifests/{reference}/_metadata/{metadata}][%d] getAcrV1NameManifestsReferenceMetadataMetadataOK  %+v", 200, o.Payload)
}

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

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

	return nil
}

func NewGetAcrV1NameManifestsReferenceMetadataMetadataBadRequest() *GetAcrV1NameManifestsReferenceMetadataMetadataBadRequest {
	return &GetAcrV1NameManifestsReferenceMetadataMetadataBadRequest{}
}

type GetAcrV1NameManifestsReferenceMetadataMetadataBadRequest struct {
	Payload *GetAcrV1NameManifestsReferenceMetadataMetadataBadRequestBody
}

func (o *GetAcrV1NameManifestsReferenceMetadataMetadataBadRequest) Error() string {
	return fmt.Sprintf("[GET /acr/v1/{name}/_manifests/{reference}/_metadata/{metadata}][%d] getAcrV1NameManifestsReferenceMetadataMetadataBadRequest  %+v", 400, o.Payload)
}

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

	o.Payload = new(GetAcrV1NameManifestsReferenceMetadataMetadataBadRequestBody)

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

	return nil
}

func NewGetAcrV1NameManifestsReferenceMetadataMetadataUnauthorized() *GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorized {
	return &GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorized{}
}

type GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorized struct {
	Payload *GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorizedBody
}

func (o *GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorized) Error() string {
	return fmt.Sprintf("[GET /acr/v1/{name}/_manifests/{reference}/_metadata/{metadata}][%d] getAcrV1NameManifestsReferenceMetadataMetadataUnauthorized  %+v", 401, o.Payload)
}

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

	o.Payload = new(GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorizedBody)

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

	return nil
}

func NewGetAcrV1NameManifestsReferenceMetadataMetadataNotFound() *GetAcrV1NameManifestsReferenceMetadataMetadataNotFound {
	return &GetAcrV1NameManifestsReferenceMetadataMetadataNotFound{}
}

type GetAcrV1NameManifestsReferenceMetadataMetadataNotFound struct {
	Payload *GetAcrV1NameManifestsReferenceMetadataMetadataNotFoundBody
}

func (o *GetAcrV1NameManifestsReferenceMetadataMetadataNotFound) Error() string {
	return fmt.Sprintf("[GET /acr/v1/{name}/_manifests/{reference}/_metadata/{metadata}][%d] getAcrV1NameManifestsReferenceMetadataMetadataNotFound  %+v", 404, o.Payload)
}

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

	o.Payload = new(GetAcrV1NameManifestsReferenceMetadataMetadataNotFoundBody)

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

	return nil
}

type GetAcrV1NameManifestsReferenceMetadataMetadataBadRequestBody struct {

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

func (o *GetAcrV1NameManifestsReferenceMetadataMetadataBadRequestBody) Validate(formats strfmt.Registry) error {
	var res []error

	if err := o.validateData(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (o *GetAcrV1NameManifestsReferenceMetadataMetadataBadRequestBody) validateData(formats strfmt.Registry) error {

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

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

	return nil
}

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

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

type GetAcrV1NameManifestsReferenceMetadataMetadataNotFoundBody struct {

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

func (o *GetAcrV1NameManifestsReferenceMetadataMetadataNotFoundBody) Validate(formats strfmt.Registry) error {
	var res []error

	if err := o.validateData(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (o *GetAcrV1NameManifestsReferenceMetadataMetadataNotFoundBody) validateData(formats strfmt.Registry) error {

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

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

	return nil
}

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

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

type GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorizedBody struct {

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

func (o *GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorizedBody) Validate(formats strfmt.Registry) error {
	var res []error

	if err := o.validateData(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (o *GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorizedBody) validateData(formats strfmt.Registry) error {

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

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

	return nil
}

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

func (o *GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorizedBody) UnmarshalBinary(b []byte) error {
	var res GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorizedBody
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*o = res
	return nil
}
// 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 (
	"fmt"
	"io"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/runtime"
	"github.com/go-openapi/swag"

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

	models "github.com/sajayantony/acrctl/models"
)

// GetAcrV1NameManifestsReferenceMetadataMetadataReader is a Reader for the GetAcrV1NameManifestsReferenceMetadataMetadata structure.
type GetAcrV1NameManifestsReferenceMetadataMetadataReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *GetAcrV1NameManifestsReferenceMetadataMetadataReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {

	case 200:
		result := NewGetAcrV1NameManifestsReferenceMetadataMetadataOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil

	case 400:
		result := NewGetAcrV1NameManifestsReferenceMetadataMetadataBadRequest()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result

	case 401:
		result := NewGetAcrV1NameManifestsReferenceMetadataMetadataUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result

	case 404:
		result := NewGetAcrV1NameManifestsReferenceMetadataMetadataNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result

	default:
		return nil, runtime.NewAPIError("unknown error", response, response.Code())
	}
}

// NewGetAcrV1NameManifestsReferenceMetadataMetadataOK creates a GetAcrV1NameManifestsReferenceMetadataMetadataOK with default headers values
func NewGetAcrV1NameManifestsReferenceMetadataMetadataOK() *GetAcrV1NameManifestsReferenceMetadataMetadataOK {
	return &GetAcrV1NameManifestsReferenceMetadataMetadataOK{}
}

/*GetAcrV1NameManifestsReferenceMetadataMetadataOK handles this case with default header values.

Returns the metadata value
*/
type GetAcrV1NameManifestsReferenceMetadataMetadataOK struct {
	Payload string
}

func (o *GetAcrV1NameManifestsReferenceMetadataMetadataOK) Error() string {
	return fmt.Sprintf("[GET /acr/v1/{name}/_manifests/{reference}/_metadata/{metadata}][%d] getAcrV1NameManifestsReferenceMetadataMetadataOK  %+v", 200, o.Payload)
}

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

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

	return nil
}

// NewGetAcrV1NameManifestsReferenceMetadataMetadataBadRequest creates a GetAcrV1NameManifestsReferenceMetadataMetadataBadRequest with default headers values
func NewGetAcrV1NameManifestsReferenceMetadataMetadataBadRequest() *GetAcrV1NameManifestsReferenceMetadataMetadataBadRequest {
	return &GetAcrV1NameManifestsReferenceMetadataMetadataBadRequest{}
}

/*GetAcrV1NameManifestsReferenceMetadataMetadataBadRequest handles this case with default header values.

On failure
*/
type GetAcrV1NameManifestsReferenceMetadataMetadataBadRequest struct {
	Payload *GetAcrV1NameManifestsReferenceMetadataMetadataBadRequestBody
}

func (o *GetAcrV1NameManifestsReferenceMetadataMetadataBadRequest) Error() string {
	return fmt.Sprintf("[GET /acr/v1/{name}/_manifests/{reference}/_metadata/{metadata}][%d] getAcrV1NameManifestsReferenceMetadataMetadataBadRequest  %+v", 400, o.Payload)
}

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

	o.Payload = new(GetAcrV1NameManifestsReferenceMetadataMetadataBadRequestBody)

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

	return nil
}

// NewGetAcrV1NameManifestsReferenceMetadataMetadataUnauthorized creates a GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorized with default headers values
func NewGetAcrV1NameManifestsReferenceMetadataMetadataUnauthorized() *GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorized {
	return &GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorized{}
}

/*GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorized handles this case with default header values.

Unauthorized access
*/
type GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorized struct {
	Payload *GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorizedBody
}

func (o *GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorized) Error() string {
	return fmt.Sprintf("[GET /acr/v1/{name}/_manifests/{reference}/_metadata/{metadata}][%d] getAcrV1NameManifestsReferenceMetadataMetadataUnauthorized  %+v", 401, o.Payload)
}

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

	o.Payload = new(GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorizedBody)

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

	return nil
}

// NewGetAcrV1NameManifestsReferenceMetadataMetadataNotFound creates a GetAcrV1NameManifestsReferenceMetadataMetadataNotFound with default headers values
func NewGetAcrV1NameManifestsReferenceMetadataMetadataNotFound() *GetAcrV1NameManifestsReferenceMetadataMetadataNotFound {
	return &GetAcrV1NameManifestsReferenceMetadataMetadataNotFound{}
}

/*GetAcrV1NameManifestsReferenceMetadataMetadataNotFound handles this case with default header values.

The repository, manifest or the metadata is unknown to the registry.
*/
type GetAcrV1NameManifestsReferenceMetadataMetadataNotFound struct {
	Payload *GetAcrV1NameManifestsReferenceMetadataMetadataNotFoundBody
}

func (o *GetAcrV1NameManifestsReferenceMetadataMetadataNotFound) Error() string {
	return fmt.Sprintf("[GET /acr/v1/{name}/_manifests/{reference}/_metadata/{metadata}][%d] getAcrV1NameManifestsReferenceMetadataMetadataNotFound  %+v", 404, o.Payload)
}

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

	o.Payload = new(GetAcrV1NameManifestsReferenceMetadataMetadataNotFoundBody)

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

	return nil
}

/*GetAcrV1NameManifestsReferenceMetadataMetadataBadRequestBody get acr v1 name manifests reference metadata metadata bad request body
swagger:model GetAcrV1NameManifestsReferenceMetadataMetadataBadRequestBody
*/
type GetAcrV1NameManifestsReferenceMetadataMetadataBadRequestBody struct {

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

// Validate validates this get acr v1 name manifests reference metadata metadata bad request body
func (o *GetAcrV1NameManifestsReferenceMetadataMetadataBadRequestBody) Validate(formats strfmt.Registry) error {
	var res []error

	if err := o.validateData(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (o *GetAcrV1NameManifestsReferenceMetadataMetadataBadRequestBody) 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("getAcrV1NameManifestsReferenceMetadataMetadataBadRequest" + "." + "data")
			}
			return err
		}
	}

	return nil
}

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

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

/*GetAcrV1NameManifestsReferenceMetadataMetadataNotFoundBody get acr v1 name manifests reference metadata metadata not found body
swagger:model GetAcrV1NameManifestsReferenceMetadataMetadataNotFoundBody
*/
type GetAcrV1NameManifestsReferenceMetadataMetadataNotFoundBody struct {

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

// Validate validates this get acr v1 name manifests reference metadata metadata not found body
func (o *GetAcrV1NameManifestsReferenceMetadataMetadataNotFoundBody) Validate(formats strfmt.Registry) error {
	var res []error

	if err := o.validateData(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (o *GetAcrV1NameManifestsReferenceMetadataMetadataNotFoundBody) 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("getAcrV1NameManifestsReferenceMetadataMetadataNotFound" + "." + "data")
			}
			return err
		}
	}

	return nil
}

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

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

/*GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorizedBody get acr v1 name manifests reference metadata metadata unauthorized body
swagger:model GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorizedBody
*/
type GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorizedBody struct {

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

// Validate validates this get acr v1 name manifests reference metadata metadata unauthorized body
func (o *GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorizedBody) Validate(formats strfmt.Registry) error {
	var res []error

	if err := o.validateData(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (o *GetAcrV1NameManifestsReferenceMetadataMetadataUnauthorizedBody) 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("getAcrV1NameManifestsReferenceMetadataMetadataUnauthorized" + "." + "data")
			}
			return err
		}
	}

	return nil
}

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

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