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

// RepoEditBranchProtectionReader is a Reader for the RepoEditBranchProtection structure.
type RepoEditBranchProtectionReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *RepoEditBranchProtectionReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewRepoEditBranchProtectionOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 404:
		result := NewRepoEditBranchProtectionNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewRepoEditBranchProtectionUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 423:
		result := NewRepoEditBranchProtectionLocked()
		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}/branch_protections/{name}] repoEditBranchProtection", response, response.Code())
	}
}

// NewRepoEditBranchProtectionOK creates a RepoEditBranchProtectionOK with default headers values
func NewRepoEditBranchProtectionOK() *RepoEditBranchProtectionOK {
	return &RepoEditBranchProtectionOK{}
}

/*
RepoEditBranchProtectionOK describes a response with status code 200, with default header values.

BranchProtection
*/
type RepoEditBranchProtectionOK struct {
	Payload *models.BranchProtection
}

// IsSuccess returns true when this repo edit branch protection o k response has a 2xx status code
func (o *RepoEditBranchProtectionOK) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this repo edit branch protection o k response has a 3xx status code
func (o *RepoEditBranchProtectionOK) IsRedirect() bool {
	return false
}

// IsClientError returns true when this repo edit branch protection o k response has a 4xx status code
func (o *RepoEditBranchProtectionOK) IsClientError() bool {
	return false
}

// IsServerError returns true when this repo edit branch protection o k response has a 5xx status code
func (o *RepoEditBranchProtectionOK) IsServerError() bool {
	return false
}

// IsCode returns true when this repo edit branch protection o k response a status code equal to that given
func (o *RepoEditBranchProtectionOK) IsCode(code int) bool {
	return code == 200
}

// Code gets the status code for the repo edit branch protection o k response
func (o *RepoEditBranchProtectionOK) Code() int {
	return 200
}

func (o *RepoEditBranchProtectionOK) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PATCH /repos/{owner}/{repo}/branch_protections/{name}][%d] repoEditBranchProtectionOK %s", 200, payload)
}

func (o *RepoEditBranchProtectionOK) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PATCH /repos/{owner}/{repo}/branch_protections/{name}][%d] repoEditBranchProtectionOK %s", 200, payload)
}

func (o *RepoEditBranchProtectionOK) GetPayload() *models.BranchProtection {
	return o.Payload
}

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

	o.Payload = new(models.BranchProtection)

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

	return nil
}

// NewRepoEditBranchProtectionNotFound creates a RepoEditBranchProtectionNotFound with default headers values
func NewRepoEditBranchProtectionNotFound() *RepoEditBranchProtectionNotFound {
	return &RepoEditBranchProtectionNotFound{}
}

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

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

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

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

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

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

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

// Code gets the status code for the repo edit branch protection not found response
func (o *RepoEditBranchProtectionNotFound) Code() int {
	return 404
}

func (o *RepoEditBranchProtectionNotFound) Error() string {
	return fmt.Sprintf("[PATCH /repos/{owner}/{repo}/branch_protections/{name}][%d] repoEditBranchProtectionNotFound", 404)
}

func (o *RepoEditBranchProtectionNotFound) String() string {
	return fmt.Sprintf("[PATCH /repos/{owner}/{repo}/branch_protections/{name}][%d] repoEditBranchProtectionNotFound", 404)
}

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

	return nil
}

// NewRepoEditBranchProtectionUnprocessableEntity creates a RepoEditBranchProtectionUnprocessableEntity with default headers values
func NewRepoEditBranchProtectionUnprocessableEntity() *RepoEditBranchProtectionUnprocessableEntity {
	return &RepoEditBranchProtectionUnprocessableEntity{}
}

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

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

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

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

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

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

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

// Code gets the status code for the repo edit branch protection unprocessable entity response
func (o *RepoEditBranchProtectionUnprocessableEntity) Code() int {
	return 422
}

func (o *RepoEditBranchProtectionUnprocessableEntity) Error() string {
	return fmt.Sprintf("[PATCH /repos/{owner}/{repo}/branch_protections/{name}][%d] repoEditBranchProtectionUnprocessableEntity", 422)
}

func (o *RepoEditBranchProtectionUnprocessableEntity) String() string {
	return fmt.Sprintf("[PATCH /repos/{owner}/{repo}/branch_protections/{name}][%d] repoEditBranchProtectionUnprocessableEntity", 422)
}

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

// NewRepoEditBranchProtectionLocked creates a RepoEditBranchProtectionLocked with default headers values
func NewRepoEditBranchProtectionLocked() *RepoEditBranchProtectionLocked {
	return &RepoEditBranchProtectionLocked{}
}

/*
RepoEditBranchProtectionLocked 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 RepoEditBranchProtectionLocked struct {
	Message string
	URL     string
}

// IsSuccess returns true when this repo edit branch protection locked response has a 2xx status code
func (o *RepoEditBranchProtectionLocked) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this repo edit branch protection locked response has a 3xx status code
func (o *RepoEditBranchProtectionLocked) IsRedirect() bool {
	return false
}

// IsClientError returns true when this repo edit branch protection locked response has a 4xx status code
func (o *RepoEditBranchProtectionLocked) IsClientError() bool {
	return true
}

// IsServerError returns true when this repo edit branch protection locked response has a 5xx status code
func (o *RepoEditBranchProtectionLocked) IsServerError() bool {
	return false
}

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

// Code gets the status code for the repo edit branch protection locked response
func (o *RepoEditBranchProtectionLocked) Code() int {
	return 423
}

func (o *RepoEditBranchProtectionLocked) Error() string {
	return fmt.Sprintf("[PATCH /repos/{owner}/{repo}/branch_protections/{name}][%d] repoEditBranchProtectionLocked", 423)
}

func (o *RepoEditBranchProtectionLocked) String() string {
	return fmt.Sprintf("[PATCH /repos/{owner}/{repo}/branch_protections/{name}][%d] repoEditBranchProtectionLocked", 423)
}

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