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

// RepoCreateFileReader is a Reader for the RepoCreateFile structure.
type RepoCreateFileReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *RepoCreateFileReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 201:
		result := NewRepoCreateFileCreated()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 403:
		result := NewRepoCreateFileForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewRepoCreateFileNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewRepoCreateFileUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 423:
		result := NewRepoCreateFileLocked()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[POST /repos/{owner}/{repo}/contents/{filepath}] repoCreateFile", response, response.Code())
	}
}

// NewRepoCreateFileCreated creates a RepoCreateFileCreated with default headers values
func NewRepoCreateFileCreated() *RepoCreateFileCreated {
	return &RepoCreateFileCreated{}
}

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

FileResponse
*/
type RepoCreateFileCreated struct {
	Payload *models.FileResponse
}

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

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

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

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

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

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

func (o *RepoCreateFileCreated) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/contents/{filepath}][%d] repoCreateFileCreated %s", 201, payload)
}

func (o *RepoCreateFileCreated) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/contents/{filepath}][%d] repoCreateFileCreated %s", 201, payload)
}

func (o *RepoCreateFileCreated) GetPayload() *models.FileResponse {
	return o.Payload
}

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

	o.Payload = new(models.FileResponse)

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

	return nil
}

// NewRepoCreateFileForbidden creates a RepoCreateFileForbidden with default headers values
func NewRepoCreateFileForbidden() *RepoCreateFileForbidden {
	return &RepoCreateFileForbidden{}
}

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

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

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

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

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

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

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

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

func (o *RepoCreateFileForbidden) Error() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/contents/{filepath}][%d] repoCreateFileForbidden", 403)
}

func (o *RepoCreateFileForbidden) String() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/contents/{filepath}][%d] repoCreateFileForbidden", 403)
}

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

// NewRepoCreateFileNotFound creates a RepoCreateFileNotFound with default headers values
func NewRepoCreateFileNotFound() *RepoCreateFileNotFound {
	return &RepoCreateFileNotFound{}
}

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

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

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

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

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

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

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

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

func (o *RepoCreateFileNotFound) Error() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/contents/{filepath}][%d] repoCreateFileNotFound", 404)
}

func (o *RepoCreateFileNotFound) String() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/contents/{filepath}][%d] repoCreateFileNotFound", 404)
}

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

	return nil
}

// NewRepoCreateFileUnprocessableEntity creates a RepoCreateFileUnprocessableEntity with default headers values
func NewRepoCreateFileUnprocessableEntity() *RepoCreateFileUnprocessableEntity {
	return &RepoCreateFileUnprocessableEntity{}
}

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

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

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

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

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

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

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

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

func (o *RepoCreateFileUnprocessableEntity) Error() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/contents/{filepath}][%d] repoCreateFileUnprocessableEntity", 422)
}

func (o *RepoCreateFileUnprocessableEntity) String() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/contents/{filepath}][%d] repoCreateFileUnprocessableEntity", 422)
}

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

// NewRepoCreateFileLocked creates a RepoCreateFileLocked with default headers values
func NewRepoCreateFileLocked() *RepoCreateFileLocked {
	return &RepoCreateFileLocked{}
}

/*
RepoCreateFileLocked describes a response with status code 423, with default header values.

APIRepoArchivedError is an error that is raised when an archived repo should be modified
*/
type RepoCreateFileLocked struct {
	Message string
	URL     string
}

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

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

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

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

// IsCode returns true when this repo create file locked response a status code equal to that given
func (o *RepoCreateFileLocked) IsCode(code int) bool {
	return code == 423
}

// Code gets the status code for the repo create file locked response
func (o *RepoCreateFileLocked) Code() int {
	return 423
}

func (o *RepoCreateFileLocked) Error() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/contents/{filepath}][%d] repoCreateFileLocked", 423)
}

func (o *RepoCreateFileLocked) String() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/contents/{filepath}][%d] repoCreateFileLocked", 423)
}

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