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

package repository

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

// CreateCurrentUserRepoReader is a Reader for the CreateCurrentUserRepo structure.
type CreateCurrentUserRepoReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *CreateCurrentUserRepoReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 201:
		result := NewCreateCurrentUserRepoCreated()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 400:
		result := NewCreateCurrentUserRepoBadRequest()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 409:
		result := NewCreateCurrentUserRepoConflict()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewCreateCurrentUserRepoUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[POST /user/repos] createCurrentUserRepo", response, response.Code())
	}
}

// NewCreateCurrentUserRepoCreated creates a CreateCurrentUserRepoCreated with default headers values
func NewCreateCurrentUserRepoCreated() *CreateCurrentUserRepoCreated {
	return &CreateCurrentUserRepoCreated{}
}

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

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

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

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

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

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

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

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

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

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

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

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

// NewCreateCurrentUserRepoBadRequest creates a CreateCurrentUserRepoBadRequest with default headers values
func NewCreateCurrentUserRepoBadRequest() *CreateCurrentUserRepoBadRequest {
	return &CreateCurrentUserRepoBadRequest{}
}

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

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

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

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

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

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

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

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

func (o *CreateCurrentUserRepoBadRequest) Error() string {
	return fmt.Sprintf("[POST /user/repos][%d] createCurrentUserRepoBadRequest", 400)
}

func (o *CreateCurrentUserRepoBadRequest) String() string {
	return fmt.Sprintf("[POST /user/repos][%d] createCurrentUserRepoBadRequest", 400)
}

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

// NewCreateCurrentUserRepoConflict creates a CreateCurrentUserRepoConflict with default headers values
func NewCreateCurrentUserRepoConflict() *CreateCurrentUserRepoConflict {
	return &CreateCurrentUserRepoConflict{}
}

/*
CreateCurrentUserRepoConflict describes a response with status code 409, with default header values.

The repository with the same name already exists.
*/
type CreateCurrentUserRepoConflict struct {
}

// IsSuccess returns true when this create current user repo conflict response has a 2xx status code
func (o *CreateCurrentUserRepoConflict) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this create current user repo conflict response has a 3xx status code
func (o *CreateCurrentUserRepoConflict) IsRedirect() bool {
	return false
}

// IsClientError returns true when this create current user repo conflict response has a 4xx status code
func (o *CreateCurrentUserRepoConflict) IsClientError() bool {
	return true
}

// IsServerError returns true when this create current user repo conflict response has a 5xx status code
func (o *CreateCurrentUserRepoConflict) IsServerError() bool {
	return false
}

// IsCode returns true when this create current user repo conflict response a status code equal to that given
func (o *CreateCurrentUserRepoConflict) IsCode(code int) bool {
	return code == 409
}

// Code gets the status code for the create current user repo conflict response
func (o *CreateCurrentUserRepoConflict) Code() int {
	return 409
}

func (o *CreateCurrentUserRepoConflict) Error() string {
	return fmt.Sprintf("[POST /user/repos][%d] createCurrentUserRepoConflict", 409)
}

func (o *CreateCurrentUserRepoConflict) String() string {
	return fmt.Sprintf("[POST /user/repos][%d] createCurrentUserRepoConflict", 409)
}

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

	return nil
}

// NewCreateCurrentUserRepoUnprocessableEntity creates a CreateCurrentUserRepoUnprocessableEntity with default headers values
func NewCreateCurrentUserRepoUnprocessableEntity() *CreateCurrentUserRepoUnprocessableEntity {
	return &CreateCurrentUserRepoUnprocessableEntity{}
}

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

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

// IsSuccess returns true when this create current user repo unprocessable entity response has a 2xx status code
func (o *CreateCurrentUserRepoUnprocessableEntity) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this create current user repo unprocessable entity response has a 3xx status code
func (o *CreateCurrentUserRepoUnprocessableEntity) IsRedirect() bool {
	return false
}

// IsClientError returns true when this create current user repo unprocessable entity response has a 4xx status code
func (o *CreateCurrentUserRepoUnprocessableEntity) IsClientError() bool {
	return true
}

// IsServerError returns true when this create current user repo unprocessable entity response has a 5xx status code
func (o *CreateCurrentUserRepoUnprocessableEntity) IsServerError() bool {
	return false
}

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

// Code gets the status code for the create current user repo unprocessable entity response
func (o *CreateCurrentUserRepoUnprocessableEntity) Code() int {
	return 422
}

func (o *CreateCurrentUserRepoUnprocessableEntity) Error() string {
	return fmt.Sprintf("[POST /user/repos][%d] createCurrentUserRepoUnprocessableEntity", 422)
}

func (o *CreateCurrentUserRepoUnprocessableEntity) String() string {
	return fmt.Sprintf("[POST /user/repos][%d] createCurrentUserRepoUnprocessableEntity", 422)
}

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