// 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 (
	"fmt"

	"github.com/go-openapi/runtime"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
)

// RepoUpdateTopicsReader is a Reader for the RepoUpdateTopics structure.
type RepoUpdateTopicsReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *RepoUpdateTopicsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 204:
		result := NewRepoUpdateTopicsNoContent()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 404:
		result := NewRepoUpdateTopicsNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 422:
		result := NewRepoUpdateTopicsUnprocessableEntity()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[PUT /repos/{owner}/{repo}/topics] repoUpdateTopics", response, response.Code())
	}
}

// NewRepoUpdateTopicsNoContent creates a RepoUpdateTopicsNoContent with default headers values
func NewRepoUpdateTopicsNoContent() *RepoUpdateTopicsNoContent {
	return &RepoUpdateTopicsNoContent{}
}

/*
RepoUpdateTopicsNoContent describes a response with status code 204, with default header values.

APIEmpty is an empty response
*/
type RepoUpdateTopicsNoContent struct {
}

// IsSuccess returns true when this repo update topics no content response has a 2xx status code
func (o *RepoUpdateTopicsNoContent) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this repo update topics no content response has a 3xx status code
func (o *RepoUpdateTopicsNoContent) IsRedirect() bool {
	return false
}

// IsClientError returns true when this repo update topics no content response has a 4xx status code
func (o *RepoUpdateTopicsNoContent) IsClientError() bool {
	return false
}

// IsServerError returns true when this repo update topics no content response has a 5xx status code
func (o *RepoUpdateTopicsNoContent) IsServerError() bool {
	return false
}

// IsCode returns true when this repo update topics no content response a status code equal to that given
func (o *RepoUpdateTopicsNoContent) IsCode(code int) bool {
	return code == 204
}

// Code gets the status code for the repo update topics no content response
func (o *RepoUpdateTopicsNoContent) Code() int {
	return 204
}

func (o *RepoUpdateTopicsNoContent) Error() string {
	return fmt.Sprintf("[PUT /repos/{owner}/{repo}/topics][%d] repoUpdateTopicsNoContent", 204)
}

func (o *RepoUpdateTopicsNoContent) String() string {
	return fmt.Sprintf("[PUT /repos/{owner}/{repo}/topics][%d] repoUpdateTopicsNoContent", 204)
}

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

	return nil
}

// NewRepoUpdateTopicsNotFound creates a RepoUpdateTopicsNotFound with default headers values
func NewRepoUpdateTopicsNotFound() *RepoUpdateTopicsNotFound {
	return &RepoUpdateTopicsNotFound{}
}

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

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

// IsSuccess returns true when this repo update topics not found response has a 2xx status code
func (o *RepoUpdateTopicsNotFound) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this repo update topics not found response has a 3xx status code
func (o *RepoUpdateTopicsNotFound) IsRedirect() bool {
	return false
}

// IsClientError returns true when this repo update topics not found response has a 4xx status code
func (o *RepoUpdateTopicsNotFound) IsClientError() bool {
	return true
}

// IsServerError returns true when this repo update topics not found response has a 5xx status code
func (o *RepoUpdateTopicsNotFound) IsServerError() bool {
	return false
}

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

// Code gets the status code for the repo update topics not found response
func (o *RepoUpdateTopicsNotFound) Code() int {
	return 404
}

func (o *RepoUpdateTopicsNotFound) Error() string {
	return fmt.Sprintf("[PUT /repos/{owner}/{repo}/topics][%d] repoUpdateTopicsNotFound", 404)
}

func (o *RepoUpdateTopicsNotFound) String() string {
	return fmt.Sprintf("[PUT /repos/{owner}/{repo}/topics][%d] repoUpdateTopicsNotFound", 404)
}

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

	return nil
}

// NewRepoUpdateTopicsUnprocessableEntity creates a RepoUpdateTopicsUnprocessableEntity with default headers values
func NewRepoUpdateTopicsUnprocessableEntity() *RepoUpdateTopicsUnprocessableEntity {
	return &RepoUpdateTopicsUnprocessableEntity{}
}

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

APIInvalidTopicsError is error format response to invalid topics
*/
type RepoUpdateTopicsUnprocessableEntity struct {
	InvalidTopics []string
	Message       string
}

// IsSuccess returns true when this repo update topics unprocessable entity response has a 2xx status code
func (o *RepoUpdateTopicsUnprocessableEntity) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this repo update topics unprocessable entity response has a 3xx status code
func (o *RepoUpdateTopicsUnprocessableEntity) IsRedirect() bool {
	return false
}

// IsClientError returns true when this repo update topics unprocessable entity response has a 4xx status code
func (o *RepoUpdateTopicsUnprocessableEntity) IsClientError() bool {
	return true
}

// IsServerError returns true when this repo update topics unprocessable entity response has a 5xx status code
func (o *RepoUpdateTopicsUnprocessableEntity) IsServerError() bool {
	return false
}

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

// Code gets the status code for the repo update topics unprocessable entity response
func (o *RepoUpdateTopicsUnprocessableEntity) Code() int {
	return 422
}

func (o *RepoUpdateTopicsUnprocessableEntity) Error() string {
	return fmt.Sprintf("[PUT /repos/{owner}/{repo}/topics][%d] repoUpdateTopicsUnprocessableEntity", 422)
}

func (o *RepoUpdateTopicsUnprocessableEntity) String() string {
	return fmt.Sprintf("[PUT /repos/{owner}/{repo}/topics][%d] repoUpdateTopicsUnprocessableEntity", 422)
}

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

	// hydrates response header invalidTopics
	hdrInvalidTopics := response.GetHeader("invalidTopics")

	if hdrInvalidTopics != "" {

		// binding header items for invalidTopics
		valInvalidTopics, err := o.bindHeaderInvalidTopics(hdrInvalidTopics, formats)
		if err != nil {
			return err
		}

		o.InvalidTopics = valInvalidTopics
	}

	// hydrates response header message
	hdrMessage := response.GetHeader("message")

	if hdrMessage != "" {
		o.Message = hdrMessage
	}

	return nil
}

// bindHeaderRepoUpdateTopicsUnprocessableEntity binds the response header invalidTopics
func (o *RepoUpdateTopicsUnprocessableEntity) bindHeaderInvalidTopics(hdr string, formats strfmt.Registry) ([]string, error) {
	invalidTopicsIV := hdr

	var (
		invalidTopicsIC []string
	)
	// items.CollectionFormat: ""
	invalidTopicsIR := swag.SplitByFormat(invalidTopicsIV, "")

	for _, invalidTopicsIIV := range invalidTopicsIR {

		// convert split string to string
		invalidTopicsIIC := invalidTopicsIIV                        // string as string
		invalidTopicsIC = append(invalidTopicsIC, invalidTopicsIIC) // roll-up string into []string
	}

	return invalidTopicsIC, nil
}
