// Code generated by go-swagger; DO NOT EDIT.

package organization

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

	"src.opensuse.org/autogits/common/gitea-generated/models"
)

// OrgCreateLabelReader is a Reader for the OrgCreateLabel structure.
type OrgCreateLabelReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *OrgCreateLabelReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 201:
		result := NewOrgCreateLabelCreated()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 404:
		result := NewOrgCreateLabelNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewOrgCreateLabelUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[POST /orgs/{org}/labels] orgCreateLabel", response, response.Code())
	}
}

// NewOrgCreateLabelCreated creates a OrgCreateLabelCreated with default headers values
func NewOrgCreateLabelCreated() *OrgCreateLabelCreated {
	return &OrgCreateLabelCreated{}
}

/*
OrgCreateLabelCreated describes a response with status code 201, with default header values.

Label
*/
type OrgCreateLabelCreated struct {
	Payload *models.Label
}

// IsSuccess returns true when this org create label created response has a 2xx status code
func (o *OrgCreateLabelCreated) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this org create label created response has a 3xx status code
func (o *OrgCreateLabelCreated) IsRedirect() bool {
	return false
}

// IsClientError returns true when this org create label created response has a 4xx status code
func (o *OrgCreateLabelCreated) IsClientError() bool {
	return false
}

// IsServerError returns true when this org create label created response has a 5xx status code
func (o *OrgCreateLabelCreated) IsServerError() bool {
	return false
}

// IsCode returns true when this org create label created response a status code equal to that given
func (o *OrgCreateLabelCreated) IsCode(code int) bool {
	return code == 201
}

// Code gets the status code for the org create label created response
func (o *OrgCreateLabelCreated) Code() int {
	return 201
}

func (o *OrgCreateLabelCreated) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /orgs/{org}/labels][%d] orgCreateLabelCreated %s", 201, payload)
}

func (o *OrgCreateLabelCreated) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /orgs/{org}/labels][%d] orgCreateLabelCreated %s", 201, payload)
}

func (o *OrgCreateLabelCreated) GetPayload() *models.Label {
	return o.Payload
}

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

	o.Payload = new(models.Label)

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

	return nil
}

// NewOrgCreateLabelNotFound creates a OrgCreateLabelNotFound with default headers values
func NewOrgCreateLabelNotFound() *OrgCreateLabelNotFound {
	return &OrgCreateLabelNotFound{}
}

/*
OrgCreateLabelNotFound describes a response with status code 404, with default header values.

APINotFound is a not found empty response
*/
type OrgCreateLabelNotFound struct {
}

// IsSuccess returns true when this org create label not found response has a 2xx status code
func (o *OrgCreateLabelNotFound) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this org create label not found response has a 3xx status code
func (o *OrgCreateLabelNotFound) IsRedirect() bool {
	return false
}

// IsClientError returns true when this org create label not found response has a 4xx status code
func (o *OrgCreateLabelNotFound) IsClientError() bool {
	return true
}

// IsServerError returns true when this org create label not found response has a 5xx status code
func (o *OrgCreateLabelNotFound) IsServerError() bool {
	return false
}

// IsCode returns true when this org create label not found response a status code equal to that given
func (o *OrgCreateLabelNotFound) IsCode(code int) bool {
	return code == 404
}

// Code gets the status code for the org create label not found response
func (o *OrgCreateLabelNotFound) Code() int {
	return 404
}

func (o *OrgCreateLabelNotFound) Error() string {
	return fmt.Sprintf("[POST /orgs/{org}/labels][%d] orgCreateLabelNotFound", 404)
}

func (o *OrgCreateLabelNotFound) String() string {
	return fmt.Sprintf("[POST /orgs/{org}/labels][%d] orgCreateLabelNotFound", 404)
}

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

	return nil
}

// NewOrgCreateLabelUnprocessableEntity creates a OrgCreateLabelUnprocessableEntity with default headers values
func NewOrgCreateLabelUnprocessableEntity() *OrgCreateLabelUnprocessableEntity {
	return &OrgCreateLabelUnprocessableEntity{}
}

/*
OrgCreateLabelUnprocessableEntity describes a response with status code 422, with default header values.

APIValidationError is error format response related to input validation
*/
type OrgCreateLabelUnprocessableEntity struct {
	Message string
	URL     string
}

// IsSuccess returns true when this org create label unprocessable entity response has a 2xx status code
func (o *OrgCreateLabelUnprocessableEntity) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this org create label unprocessable entity response has a 3xx status code
func (o *OrgCreateLabelUnprocessableEntity) IsRedirect() bool {
	return false
}

// IsClientError returns true when this org create label unprocessable entity response has a 4xx status code
func (o *OrgCreateLabelUnprocessableEntity) IsClientError() bool {
	return true
}

// IsServerError returns true when this org create label unprocessable entity response has a 5xx status code
func (o *OrgCreateLabelUnprocessableEntity) IsServerError() bool {
	return false
}

// IsCode returns true when this org create label unprocessable entity response a status code equal to that given
func (o *OrgCreateLabelUnprocessableEntity) IsCode(code int) bool {
	return code == 422
}

// Code gets the status code for the org create label unprocessable entity response
func (o *OrgCreateLabelUnprocessableEntity) Code() int {
	return 422
}

func (o *OrgCreateLabelUnprocessableEntity) Error() string {
	return fmt.Sprintf("[POST /orgs/{org}/labels][%d] orgCreateLabelUnprocessableEntity", 422)
}

func (o *OrgCreateLabelUnprocessableEntity) String() string {
	return fmt.Sprintf("[POST /orgs/{org}/labels][%d] orgCreateLabelUnprocessableEntity", 422)
}

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

	// hydrates response header message
	hdrMessage := response.GetHeader("message")

	if hdrMessage != "" {
		o.Message = hdrMessage
	}

	// hydrates response header url
	hdrURL := response.GetHeader("url")

	if hdrURL != "" {
		o.URL = hdrURL
	}

	return nil
}
