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

// ListCredentialsReader is a Reader for the ListCredentials structure.
type ListCredentialsReader struct {
	formats strfmt.Registry
}

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

// NewListCredentialsOK creates a ListCredentialsOK with default headers values
func NewListCredentialsOK() *ListCredentialsOK {
	return &ListCredentialsOK{}
}

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

Credentials
*/
type ListCredentialsOK struct {
	Payload garm_params.Credentials
}

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

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

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

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

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

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

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

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

func (o *ListCredentialsOK) GetPayload() garm_params.Credentials {
	return o.Payload
}

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

// NewListCredentialsBadRequest creates a ListCredentialsBadRequest with default headers values
func NewListCredentialsBadRequest() *ListCredentialsBadRequest {
	return &ListCredentialsBadRequest{}
}

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

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

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

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

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

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

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

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

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

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

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

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