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

// RepoEditPullRequestReader is a Reader for the RepoEditPullRequest structure.
type RepoEditPullRequestReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *RepoEditPullRequestReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 201:
		result := NewRepoEditPullRequestCreated()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 403:
		result := NewRepoEditPullRequestForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewRepoEditPullRequestNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 409:
		result := NewRepoEditPullRequestConflict()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 412:
		result := NewRepoEditPullRequestPreconditionFailed()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewRepoEditPullRequestUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[PATCH /repos/{owner}/{repo}/pulls/{index}] repoEditPullRequest", response, response.Code())
	}
}

// NewRepoEditPullRequestCreated creates a RepoEditPullRequestCreated with default headers values
func NewRepoEditPullRequestCreated() *RepoEditPullRequestCreated {
	return &RepoEditPullRequestCreated{}
}

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

PullRequest
*/
type RepoEditPullRequestCreated struct {
	Payload *models.PullRequest
}

// IsSuccess returns true when this repo edit pull request created response has a 2xx status code
func (o *RepoEditPullRequestCreated) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this repo edit pull request created response has a 3xx status code
func (o *RepoEditPullRequestCreated) IsRedirect() bool {
	return false
}

// IsClientError returns true when this repo edit pull request created response has a 4xx status code
func (o *RepoEditPullRequestCreated) IsClientError() bool {
	return false
}

// IsServerError returns true when this repo edit pull request created response has a 5xx status code
func (o *RepoEditPullRequestCreated) IsServerError() bool {
	return false
}

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

// Code gets the status code for the repo edit pull request created response
func (o *RepoEditPullRequestCreated) Code() int {
	return 201
}

func (o *RepoEditPullRequestCreated) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PATCH /repos/{owner}/{repo}/pulls/{index}][%d] repoEditPullRequestCreated %s", 201, payload)
}

func (o *RepoEditPullRequestCreated) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PATCH /repos/{owner}/{repo}/pulls/{index}][%d] repoEditPullRequestCreated %s", 201, payload)
}

func (o *RepoEditPullRequestCreated) GetPayload() *models.PullRequest {
	return o.Payload
}

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

	o.Payload = new(models.PullRequest)

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

	return nil
}

// NewRepoEditPullRequestForbidden creates a RepoEditPullRequestForbidden with default headers values
func NewRepoEditPullRequestForbidden() *RepoEditPullRequestForbidden {
	return &RepoEditPullRequestForbidden{}
}

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

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

// IsSuccess returns true when this repo edit pull request forbidden response has a 2xx status code
func (o *RepoEditPullRequestForbidden) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this repo edit pull request forbidden response has a 3xx status code
func (o *RepoEditPullRequestForbidden) IsRedirect() bool {
	return false
}

// IsClientError returns true when this repo edit pull request forbidden response has a 4xx status code
func (o *RepoEditPullRequestForbidden) IsClientError() bool {
	return true
}

// IsServerError returns true when this repo edit pull request forbidden response has a 5xx status code
func (o *RepoEditPullRequestForbidden) IsServerError() bool {
	return false
}

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

// Code gets the status code for the repo edit pull request forbidden response
func (o *RepoEditPullRequestForbidden) Code() int {
	return 403
}

func (o *RepoEditPullRequestForbidden) Error() string {
	return fmt.Sprintf("[PATCH /repos/{owner}/{repo}/pulls/{index}][%d] repoEditPullRequestForbidden", 403)
}

func (o *RepoEditPullRequestForbidden) String() string {
	return fmt.Sprintf("[PATCH /repos/{owner}/{repo}/pulls/{index}][%d] repoEditPullRequestForbidden", 403)
}

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

// NewRepoEditPullRequestNotFound creates a RepoEditPullRequestNotFound with default headers values
func NewRepoEditPullRequestNotFound() *RepoEditPullRequestNotFound {
	return &RepoEditPullRequestNotFound{}
}

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

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

// IsSuccess returns true when this repo edit pull request not found response has a 2xx status code
func (o *RepoEditPullRequestNotFound) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this repo edit pull request not found response has a 3xx status code
func (o *RepoEditPullRequestNotFound) IsRedirect() bool {
	return false
}

// IsClientError returns true when this repo edit pull request not found response has a 4xx status code
func (o *RepoEditPullRequestNotFound) IsClientError() bool {
	return true
}

// IsServerError returns true when this repo edit pull request not found response has a 5xx status code
func (o *RepoEditPullRequestNotFound) IsServerError() bool {
	return false
}

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

// Code gets the status code for the repo edit pull request not found response
func (o *RepoEditPullRequestNotFound) Code() int {
	return 404
}

func (o *RepoEditPullRequestNotFound) Error() string {
	return fmt.Sprintf("[PATCH /repos/{owner}/{repo}/pulls/{index}][%d] repoEditPullRequestNotFound", 404)
}

func (o *RepoEditPullRequestNotFound) String() string {
	return fmt.Sprintf("[PATCH /repos/{owner}/{repo}/pulls/{index}][%d] repoEditPullRequestNotFound", 404)
}

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

	return nil
}

// NewRepoEditPullRequestConflict creates a RepoEditPullRequestConflict with default headers values
func NewRepoEditPullRequestConflict() *RepoEditPullRequestConflict {
	return &RepoEditPullRequestConflict{}
}

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

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

// IsSuccess returns true when this repo edit pull request conflict response has a 2xx status code
func (o *RepoEditPullRequestConflict) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this repo edit pull request conflict response has a 3xx status code
func (o *RepoEditPullRequestConflict) IsRedirect() bool {
	return false
}

// IsClientError returns true when this repo edit pull request conflict response has a 4xx status code
func (o *RepoEditPullRequestConflict) IsClientError() bool {
	return true
}

// IsServerError returns true when this repo edit pull request conflict response has a 5xx status code
func (o *RepoEditPullRequestConflict) IsServerError() bool {
	return false
}

// IsCode returns true when this repo edit pull request conflict response a status code equal to that given
func (o *RepoEditPullRequestConflict) IsCode(code int) bool {
	return code == 409
}

// Code gets the status code for the repo edit pull request conflict response
func (o *RepoEditPullRequestConflict) Code() int {
	return 409
}

func (o *RepoEditPullRequestConflict) Error() string {
	return fmt.Sprintf("[PATCH /repos/{owner}/{repo}/pulls/{index}][%d] repoEditPullRequestConflict", 409)
}

func (o *RepoEditPullRequestConflict) String() string {
	return fmt.Sprintf("[PATCH /repos/{owner}/{repo}/pulls/{index}][%d] repoEditPullRequestConflict", 409)
}

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

// NewRepoEditPullRequestPreconditionFailed creates a RepoEditPullRequestPreconditionFailed with default headers values
func NewRepoEditPullRequestPreconditionFailed() *RepoEditPullRequestPreconditionFailed {
	return &RepoEditPullRequestPreconditionFailed{}
}

/*
RepoEditPullRequestPreconditionFailed describes a response with status code 412, with default header values.

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

// IsSuccess returns true when this repo edit pull request precondition failed response has a 2xx status code
func (o *RepoEditPullRequestPreconditionFailed) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this repo edit pull request precondition failed response has a 3xx status code
func (o *RepoEditPullRequestPreconditionFailed) IsRedirect() bool {
	return false
}

// IsClientError returns true when this repo edit pull request precondition failed response has a 4xx status code
func (o *RepoEditPullRequestPreconditionFailed) IsClientError() bool {
	return true
}

// IsServerError returns true when this repo edit pull request precondition failed response has a 5xx status code
func (o *RepoEditPullRequestPreconditionFailed) IsServerError() bool {
	return false
}

// IsCode returns true when this repo edit pull request precondition failed response a status code equal to that given
func (o *RepoEditPullRequestPreconditionFailed) IsCode(code int) bool {
	return code == 412
}

// Code gets the status code for the repo edit pull request precondition failed response
func (o *RepoEditPullRequestPreconditionFailed) Code() int {
	return 412
}

func (o *RepoEditPullRequestPreconditionFailed) Error() string {
	return fmt.Sprintf("[PATCH /repos/{owner}/{repo}/pulls/{index}][%d] repoEditPullRequestPreconditionFailed", 412)
}

func (o *RepoEditPullRequestPreconditionFailed) String() string {
	return fmt.Sprintf("[PATCH /repos/{owner}/{repo}/pulls/{index}][%d] repoEditPullRequestPreconditionFailed", 412)
}

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

// NewRepoEditPullRequestUnprocessableEntity creates a RepoEditPullRequestUnprocessableEntity with default headers values
func NewRepoEditPullRequestUnprocessableEntity() *RepoEditPullRequestUnprocessableEntity {
	return &RepoEditPullRequestUnprocessableEntity{}
}

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

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

// IsSuccess returns true when this repo edit pull request unprocessable entity response has a 2xx status code
func (o *RepoEditPullRequestUnprocessableEntity) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this repo edit pull request unprocessable entity response has a 3xx status code
func (o *RepoEditPullRequestUnprocessableEntity) IsRedirect() bool {
	return false
}

// IsClientError returns true when this repo edit pull request unprocessable entity response has a 4xx status code
func (o *RepoEditPullRequestUnprocessableEntity) IsClientError() bool {
	return true
}

// IsServerError returns true when this repo edit pull request unprocessable entity response has a 5xx status code
func (o *RepoEditPullRequestUnprocessableEntity) IsServerError() bool {
	return false
}

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

// Code gets the status code for the repo edit pull request unprocessable entity response
func (o *RepoEditPullRequestUnprocessableEntity) Code() int {
	return 422
}

func (o *RepoEditPullRequestUnprocessableEntity) Error() string {
	return fmt.Sprintf("[PATCH /repos/{owner}/{repo}/pulls/{index}][%d] repoEditPullRequestUnprocessableEntity", 422)
}

func (o *RepoEditPullRequestUnprocessableEntity) String() string {
	return fmt.Sprintf("[PATCH /repos/{owner}/{repo}/pulls/{index}][%d] repoEditPullRequestUnprocessableEntity", 422)
}

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