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

// RepoAddPushMirrorReader is a Reader for the RepoAddPushMirror structure.
type RepoAddPushMirrorReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *RepoAddPushMirrorReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewRepoAddPushMirrorOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 400:
		result := NewRepoAddPushMirrorBadRequest()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 403:
		result := NewRepoAddPushMirrorForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewRepoAddPushMirrorNotFound()
		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}/push_mirrors] repoAddPushMirror", response, response.Code())
	}
}

// NewRepoAddPushMirrorOK creates a RepoAddPushMirrorOK with default headers values
func NewRepoAddPushMirrorOK() *RepoAddPushMirrorOK {
	return &RepoAddPushMirrorOK{}
}

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

PushMirror
*/
type RepoAddPushMirrorOK struct {
	Payload *models.PushMirror
}

// IsSuccess returns true when this repo add push mirror o k response has a 2xx status code
func (o *RepoAddPushMirrorOK) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this repo add push mirror o k response has a 3xx status code
func (o *RepoAddPushMirrorOK) IsRedirect() bool {
	return false
}

// IsClientError returns true when this repo add push mirror o k response has a 4xx status code
func (o *RepoAddPushMirrorOK) IsClientError() bool {
	return false
}

// IsServerError returns true when this repo add push mirror o k response has a 5xx status code
func (o *RepoAddPushMirrorOK) IsServerError() bool {
	return false
}

// IsCode returns true when this repo add push mirror o k response a status code equal to that given
func (o *RepoAddPushMirrorOK) IsCode(code int) bool {
	return code == 200
}

// Code gets the status code for the repo add push mirror o k response
func (o *RepoAddPushMirrorOK) Code() int {
	return 200
}

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

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

func (o *RepoAddPushMirrorOK) GetPayload() *models.PushMirror {
	return o.Payload
}

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

	o.Payload = new(models.PushMirror)

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

	return nil
}

// NewRepoAddPushMirrorBadRequest creates a RepoAddPushMirrorBadRequest with default headers values
func NewRepoAddPushMirrorBadRequest() *RepoAddPushMirrorBadRequest {
	return &RepoAddPushMirrorBadRequest{}
}

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

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

// IsSuccess returns true when this repo add push mirror bad request response has a 2xx status code
func (o *RepoAddPushMirrorBadRequest) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this repo add push mirror bad request response has a 3xx status code
func (o *RepoAddPushMirrorBadRequest) IsRedirect() bool {
	return false
}

// IsClientError returns true when this repo add push mirror bad request response has a 4xx status code
func (o *RepoAddPushMirrorBadRequest) IsClientError() bool {
	return true
}

// IsServerError returns true when this repo add push mirror bad request response has a 5xx status code
func (o *RepoAddPushMirrorBadRequest) IsServerError() bool {
	return false
}

// IsCode returns true when this repo add push mirror bad request response a status code equal to that given
func (o *RepoAddPushMirrorBadRequest) IsCode(code int) bool {
	return code == 400
}

// Code gets the status code for the repo add push mirror bad request response
func (o *RepoAddPushMirrorBadRequest) Code() int {
	return 400
}

func (o *RepoAddPushMirrorBadRequest) Error() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/push_mirrors][%d] repoAddPushMirrorBadRequest", 400)
}

func (o *RepoAddPushMirrorBadRequest) String() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/push_mirrors][%d] repoAddPushMirrorBadRequest", 400)
}

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

// NewRepoAddPushMirrorForbidden creates a RepoAddPushMirrorForbidden with default headers values
func NewRepoAddPushMirrorForbidden() *RepoAddPushMirrorForbidden {
	return &RepoAddPushMirrorForbidden{}
}

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

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

// IsSuccess returns true when this repo add push mirror forbidden response has a 2xx status code
func (o *RepoAddPushMirrorForbidden) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this repo add push mirror forbidden response has a 3xx status code
func (o *RepoAddPushMirrorForbidden) IsRedirect() bool {
	return false
}

// IsClientError returns true when this repo add push mirror forbidden response has a 4xx status code
func (o *RepoAddPushMirrorForbidden) IsClientError() bool {
	return true
}

// IsServerError returns true when this repo add push mirror forbidden response has a 5xx status code
func (o *RepoAddPushMirrorForbidden) IsServerError() bool {
	return false
}

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

// Code gets the status code for the repo add push mirror forbidden response
func (o *RepoAddPushMirrorForbidden) Code() int {
	return 403
}

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

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

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

// NewRepoAddPushMirrorNotFound creates a RepoAddPushMirrorNotFound with default headers values
func NewRepoAddPushMirrorNotFound() *RepoAddPushMirrorNotFound {
	return &RepoAddPushMirrorNotFound{}
}

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

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

// IsSuccess returns true when this repo add push mirror not found response has a 2xx status code
func (o *RepoAddPushMirrorNotFound) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this repo add push mirror not found response has a 3xx status code
func (o *RepoAddPushMirrorNotFound) IsRedirect() bool {
	return false
}

// IsClientError returns true when this repo add push mirror not found response has a 4xx status code
func (o *RepoAddPushMirrorNotFound) IsClientError() bool {
	return true
}

// IsServerError returns true when this repo add push mirror not found response has a 5xx status code
func (o *RepoAddPushMirrorNotFound) IsServerError() bool {
	return false
}

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

// Code gets the status code for the repo add push mirror not found response
func (o *RepoAddPushMirrorNotFound) Code() int {
	return 404
}

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

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

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

	return nil
}
