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

// RepoCreateBranchProtectionReader is a Reader for the RepoCreateBranchProtection structure.
type RepoCreateBranchProtectionReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *RepoCreateBranchProtectionReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 201:
		result := NewRepoCreateBranchProtectionCreated()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 403:
		result := NewRepoCreateBranchProtectionForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewRepoCreateBranchProtectionNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewRepoCreateBranchProtectionUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 423:
		result := NewRepoCreateBranchProtectionLocked()
		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}/branch_protections] repoCreateBranchProtection", response, response.Code())
	}
}

// NewRepoCreateBranchProtectionCreated creates a RepoCreateBranchProtectionCreated with default headers values
func NewRepoCreateBranchProtectionCreated() *RepoCreateBranchProtectionCreated {
	return &RepoCreateBranchProtectionCreated{}
}

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

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

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

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

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

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

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

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

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

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

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

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

// NewRepoCreateBranchProtectionForbidden creates a RepoCreateBranchProtectionForbidden with default headers values
func NewRepoCreateBranchProtectionForbidden() *RepoCreateBranchProtectionForbidden {
	return &RepoCreateBranchProtectionForbidden{}
}

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

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

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

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

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

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

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

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

func (o *RepoCreateBranchProtectionForbidden) Error() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/branch_protections][%d] repoCreateBranchProtectionForbidden", 403)
}

func (o *RepoCreateBranchProtectionForbidden) String() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/branch_protections][%d] repoCreateBranchProtectionForbidden", 403)
}

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

// NewRepoCreateBranchProtectionNotFound creates a RepoCreateBranchProtectionNotFound with default headers values
func NewRepoCreateBranchProtectionNotFound() *RepoCreateBranchProtectionNotFound {
	return &RepoCreateBranchProtectionNotFound{}
}

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

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

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

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

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

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

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

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

func (o *RepoCreateBranchProtectionNotFound) Error() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/branch_protections][%d] repoCreateBranchProtectionNotFound", 404)
}

func (o *RepoCreateBranchProtectionNotFound) String() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/branch_protections][%d] repoCreateBranchProtectionNotFound", 404)
}

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

	return nil
}

// NewRepoCreateBranchProtectionUnprocessableEntity creates a RepoCreateBranchProtectionUnprocessableEntity with default headers values
func NewRepoCreateBranchProtectionUnprocessableEntity() *RepoCreateBranchProtectionUnprocessableEntity {
	return &RepoCreateBranchProtectionUnprocessableEntity{}
}

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

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

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

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

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

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

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

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

func (o *RepoCreateBranchProtectionUnprocessableEntity) Error() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/branch_protections][%d] repoCreateBranchProtectionUnprocessableEntity", 422)
}

func (o *RepoCreateBranchProtectionUnprocessableEntity) String() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/branch_protections][%d] repoCreateBranchProtectionUnprocessableEntity", 422)
}

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

// NewRepoCreateBranchProtectionLocked creates a RepoCreateBranchProtectionLocked with default headers values
func NewRepoCreateBranchProtectionLocked() *RepoCreateBranchProtectionLocked {
	return &RepoCreateBranchProtectionLocked{}
}

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

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

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

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

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

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

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

func (o *RepoCreateBranchProtectionLocked) Error() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/branch_protections][%d] repoCreateBranchProtectionLocked", 423)
}

func (o *RepoCreateBranchProtectionLocked) String() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/branch_protections][%d] repoCreateBranchProtectionLocked", 423)
}

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