// Code generated by go-swagger; DO NOT EDIT.

package issue

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

// IssueCreateIssueAttachmentReader is a Reader for the IssueCreateIssueAttachment structure.
type IssueCreateIssueAttachmentReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *IssueCreateIssueAttachmentReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 201:
		result := NewIssueCreateIssueAttachmentCreated()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 400:
		result := NewIssueCreateIssueAttachmentBadRequest()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewIssueCreateIssueAttachmentNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewIssueCreateIssueAttachmentUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 423:
		result := NewIssueCreateIssueAttachmentLocked()
		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}/issues/{index}/assets] issueCreateIssueAttachment", response, response.Code())
	}
}

// NewIssueCreateIssueAttachmentCreated creates a IssueCreateIssueAttachmentCreated with default headers values
func NewIssueCreateIssueAttachmentCreated() *IssueCreateIssueAttachmentCreated {
	return &IssueCreateIssueAttachmentCreated{}
}

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

Attachment
*/
type IssueCreateIssueAttachmentCreated struct {
	Payload *models.Attachment
}

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

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

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

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

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

// Code gets the status code for the issue create issue attachment created response
func (o *IssueCreateIssueAttachmentCreated) Code() int {
	return 201
}

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

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

func (o *IssueCreateIssueAttachmentCreated) GetPayload() *models.Attachment {
	return o.Payload
}

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

	o.Payload = new(models.Attachment)

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

	return nil
}

// NewIssueCreateIssueAttachmentBadRequest creates a IssueCreateIssueAttachmentBadRequest with default headers values
func NewIssueCreateIssueAttachmentBadRequest() *IssueCreateIssueAttachmentBadRequest {
	return &IssueCreateIssueAttachmentBadRequest{}
}

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

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

// IsSuccess returns true when this issue create issue attachment bad request response has a 2xx status code
func (o *IssueCreateIssueAttachmentBadRequest) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this issue create issue attachment bad request response has a 3xx status code
func (o *IssueCreateIssueAttachmentBadRequest) IsRedirect() bool {
	return false
}

// IsClientError returns true when this issue create issue attachment bad request response has a 4xx status code
func (o *IssueCreateIssueAttachmentBadRequest) IsClientError() bool {
	return true
}

// IsServerError returns true when this issue create issue attachment bad request response has a 5xx status code
func (o *IssueCreateIssueAttachmentBadRequest) IsServerError() bool {
	return false
}

// IsCode returns true when this issue create issue attachment bad request response a status code equal to that given
func (o *IssueCreateIssueAttachmentBadRequest) IsCode(code int) bool {
	return code == 400
}

// Code gets the status code for the issue create issue attachment bad request response
func (o *IssueCreateIssueAttachmentBadRequest) Code() int {
	return 400
}

func (o *IssueCreateIssueAttachmentBadRequest) Error() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/issues/{index}/assets][%d] issueCreateIssueAttachmentBadRequest", 400)
}

func (o *IssueCreateIssueAttachmentBadRequest) String() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/issues/{index}/assets][%d] issueCreateIssueAttachmentBadRequest", 400)
}

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

// NewIssueCreateIssueAttachmentNotFound creates a IssueCreateIssueAttachmentNotFound with default headers values
func NewIssueCreateIssueAttachmentNotFound() *IssueCreateIssueAttachmentNotFound {
	return &IssueCreateIssueAttachmentNotFound{}
}

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

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

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

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

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

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

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

// Code gets the status code for the issue create issue attachment not found response
func (o *IssueCreateIssueAttachmentNotFound) Code() int {
	return 404
}

func (o *IssueCreateIssueAttachmentNotFound) Error() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/issues/{index}/assets][%d] issueCreateIssueAttachmentNotFound", 404)
}

func (o *IssueCreateIssueAttachmentNotFound) String() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/issues/{index}/assets][%d] issueCreateIssueAttachmentNotFound", 404)
}

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

// NewIssueCreateIssueAttachmentUnprocessableEntity creates a IssueCreateIssueAttachmentUnprocessableEntity with default headers values
func NewIssueCreateIssueAttachmentUnprocessableEntity() *IssueCreateIssueAttachmentUnprocessableEntity {
	return &IssueCreateIssueAttachmentUnprocessableEntity{}
}

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

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

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

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

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

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

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

// Code gets the status code for the issue create issue attachment unprocessable entity response
func (o *IssueCreateIssueAttachmentUnprocessableEntity) Code() int {
	return 422
}

func (o *IssueCreateIssueAttachmentUnprocessableEntity) Error() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/issues/{index}/assets][%d] issueCreateIssueAttachmentUnprocessableEntity", 422)
}

func (o *IssueCreateIssueAttachmentUnprocessableEntity) String() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/issues/{index}/assets][%d] issueCreateIssueAttachmentUnprocessableEntity", 422)
}

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

// NewIssueCreateIssueAttachmentLocked creates a IssueCreateIssueAttachmentLocked with default headers values
func NewIssueCreateIssueAttachmentLocked() *IssueCreateIssueAttachmentLocked {
	return &IssueCreateIssueAttachmentLocked{}
}

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

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

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

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

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

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

// Code gets the status code for the issue create issue attachment locked response
func (o *IssueCreateIssueAttachmentLocked) Code() int {
	return 423
}

func (o *IssueCreateIssueAttachmentLocked) Error() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/issues/{index}/assets][%d] issueCreateIssueAttachmentLocked", 423)
}

func (o *IssueCreateIssueAttachmentLocked) String() string {
	return fmt.Sprintf("[POST /repos/{owner}/{repo}/issues/{index}/assets][%d] issueCreateIssueAttachmentLocked", 423)
}

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