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

// CreateOrgRepoReader is a Reader for the CreateOrgRepo structure.
type CreateOrgRepoReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *CreateOrgRepoReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 201:
		result := NewCreateOrgRepoCreated()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 400:
		result := NewCreateOrgRepoBadRequest()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 403:
		result := NewCreateOrgRepoForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewCreateOrgRepoNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[POST /orgs/{org}/repos] createOrgRepo", response, response.Code())
	}
}

// NewCreateOrgRepoCreated creates a CreateOrgRepoCreated with default headers values
func NewCreateOrgRepoCreated() *CreateOrgRepoCreated {
	return &CreateOrgRepoCreated{}
}

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

Repository
*/
type CreateOrgRepoCreated struct {
	Payload *models.Repository
}

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

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

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

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

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

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

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

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

func (o *CreateOrgRepoCreated) GetPayload() *models.Repository {
	return o.Payload
}

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

	o.Payload = new(models.Repository)

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

	return nil
}

// NewCreateOrgRepoBadRequest creates a CreateOrgRepoBadRequest with default headers values
func NewCreateOrgRepoBadRequest() *CreateOrgRepoBadRequest {
	return &CreateOrgRepoBadRequest{}
}

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

APIError is error format response
*/
type CreateOrgRepoBadRequest struct {
	Message string
	URL     string
}

// IsSuccess returns true when this create org repo bad request response has a 2xx status code
func (o *CreateOrgRepoBadRequest) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this create org repo bad request response has a 3xx status code
func (o *CreateOrgRepoBadRequest) IsRedirect() bool {
	return false
}

// IsClientError returns true when this create org repo bad request response has a 4xx status code
func (o *CreateOrgRepoBadRequest) IsClientError() bool {
	return true
}

// IsServerError returns true when this create org repo bad request response has a 5xx status code
func (o *CreateOrgRepoBadRequest) IsServerError() bool {
	return false
}

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

// Code gets the status code for the create org repo bad request response
func (o *CreateOrgRepoBadRequest) Code() int {
	return 400
}

func (o *CreateOrgRepoBadRequest) Error() string {
	return fmt.Sprintf("[POST /orgs/{org}/repos][%d] createOrgRepoBadRequest", 400)
}

func (o *CreateOrgRepoBadRequest) String() string {
	return fmt.Sprintf("[POST /orgs/{org}/repos][%d] createOrgRepoBadRequest", 400)
}

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

// NewCreateOrgRepoForbidden creates a CreateOrgRepoForbidden with default headers values
func NewCreateOrgRepoForbidden() *CreateOrgRepoForbidden {
	return &CreateOrgRepoForbidden{}
}

/*
CreateOrgRepoForbidden describes a response with status code 403, with default header values.

APIForbiddenError is a forbidden error response
*/
type CreateOrgRepoForbidden struct {
	Message string
	URL     string
}

// IsSuccess returns true when this create org repo forbidden response has a 2xx status code
func (o *CreateOrgRepoForbidden) IsSuccess() bool {
	return false
}

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

// IsClientError returns true when this create org repo forbidden response has a 4xx status code
func (o *CreateOrgRepoForbidden) IsClientError() bool {
	return true
}

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

// IsCode returns true when this create org repo forbidden response a status code equal to that given
func (o *CreateOrgRepoForbidden) IsCode(code int) bool {
	return code == 403
}

// Code gets the status code for the create org repo forbidden response
func (o *CreateOrgRepoForbidden) Code() int {
	return 403
}

func (o *CreateOrgRepoForbidden) Error() string {
	return fmt.Sprintf("[POST /orgs/{org}/repos][%d] createOrgRepoForbidden", 403)
}

func (o *CreateOrgRepoForbidden) String() string {
	return fmt.Sprintf("[POST /orgs/{org}/repos][%d] createOrgRepoForbidden", 403)
}

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

// NewCreateOrgRepoNotFound creates a CreateOrgRepoNotFound with default headers values
func NewCreateOrgRepoNotFound() *CreateOrgRepoNotFound {
	return &CreateOrgRepoNotFound{}
}

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

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

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

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

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

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

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

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

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

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

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

	return nil
}
