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

package credentials

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

	apiserver_params "github.com/cloudbase/garm/apiserver/params"
	garm_params "github.com/cloudbase/garm/params"
)

// UpdateCredentialsReader is a Reader for the UpdateCredentials structure.
type UpdateCredentialsReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *UpdateCredentialsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewUpdateCredentialsOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 400:
		result := NewUpdateCredentialsBadRequest()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[PUT /github/credentials/{id}] UpdateCredentials", response, response.Code())
	}
}

// NewUpdateCredentialsOK creates a UpdateCredentialsOK with default headers values
func NewUpdateCredentialsOK() *UpdateCredentialsOK {
	return &UpdateCredentialsOK{}
}

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

GithubCredentials
*/
type UpdateCredentialsOK struct {
	Payload garm_params.GithubCredentials
}

// IsSuccess returns true when this update credentials o k response has a 2xx status code
func (o *UpdateCredentialsOK) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this update credentials o k response has a 3xx status code
func (o *UpdateCredentialsOK) IsRedirect() bool {
	return false
}

// IsClientError returns true when this update credentials o k response has a 4xx status code
func (o *UpdateCredentialsOK) IsClientError() bool {
	return false
}

// IsServerError returns true when this update credentials o k response has a 5xx status code
func (o *UpdateCredentialsOK) IsServerError() bool {
	return false
}

// IsCode returns true when this update credentials o k response a status code equal to that given
func (o *UpdateCredentialsOK) IsCode(code int) bool {
	return code == 200
}

// Code gets the status code for the update credentials o k response
func (o *UpdateCredentialsOK) Code() int {
	return 200
}

func (o *UpdateCredentialsOK) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /github/credentials/{id}][%d] updateCredentialsOK %s", 200, payload)
}

func (o *UpdateCredentialsOK) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /github/credentials/{id}][%d] updateCredentialsOK %s", 200, payload)
}

func (o *UpdateCredentialsOK) GetPayload() garm_params.GithubCredentials {
	return o.Payload
}

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

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

	return nil
}

// NewUpdateCredentialsBadRequest creates a UpdateCredentialsBadRequest with default headers values
func NewUpdateCredentialsBadRequest() *UpdateCredentialsBadRequest {
	return &UpdateCredentialsBadRequest{}
}

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

APIErrorResponse
*/
type UpdateCredentialsBadRequest struct {
	Payload apiserver_params.APIErrorResponse
}

// IsSuccess returns true when this update credentials bad request response has a 2xx status code
func (o *UpdateCredentialsBadRequest) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this update credentials bad request response has a 3xx status code
func (o *UpdateCredentialsBadRequest) IsRedirect() bool {
	return false
}

// IsClientError returns true when this update credentials bad request response has a 4xx status code
func (o *UpdateCredentialsBadRequest) IsClientError() bool {
	return true
}

// IsServerError returns true when this update credentials bad request response has a 5xx status code
func (o *UpdateCredentialsBadRequest) IsServerError() bool {
	return false
}

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

// Code gets the status code for the update credentials bad request response
func (o *UpdateCredentialsBadRequest) Code() int {
	return 400
}

func (o *UpdateCredentialsBadRequest) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /github/credentials/{id}][%d] updateCredentialsBadRequest %s", 400, payload)
}

func (o *UpdateCredentialsBadRequest) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /github/credentials/{id}][%d] updateCredentialsBadRequest %s", 400, payload)
}

func (o *UpdateCredentialsBadRequest) GetPayload() apiserver_params.APIErrorResponse {
	return o.Payload
}

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

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

	return nil
}
