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

package datasources

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

	"github.com/grafana/grafana-openapi-client-go/models"
)

// CallDatasourceResourceByIDReader is a Reader for the CallDatasourceResourceByID structure.
type CallDatasourceResourceByIDReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *CallDatasourceResourceByIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewCallDatasourceResourceByIDOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 400:
		result := NewCallDatasourceResourceByIDBadRequest()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 401:
		result := NewCallDatasourceResourceByIDUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 403:
		result := NewCallDatasourceResourceByIDForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewCallDatasourceResourceByIDNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 500:
		result := NewCallDatasourceResourceByIDInternalServerError()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[GET /datasources/{id}/resources/{datasource_proxy_route}] callDatasourceResourceByID", response, response.Code())
	}
}

// NewCallDatasourceResourceByIDOK creates a CallDatasourceResourceByIDOK with default headers values
func NewCallDatasourceResourceByIDOK() *CallDatasourceResourceByIDOK {
	return &CallDatasourceResourceByIDOK{}
}

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

An OKResponse is returned if the request was successful.
*/
type CallDatasourceResourceByIDOK struct {
	Payload *models.SuccessResponseBody
}

// IsSuccess returns true when this call datasource resource by Id Ok response has a 2xx status code
func (o *CallDatasourceResourceByIDOK) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this call datasource resource by Id Ok response has a 3xx status code
func (o *CallDatasourceResourceByIDOK) IsRedirect() bool {
	return false
}

// IsClientError returns true when this call datasource resource by Id Ok response has a 4xx status code
func (o *CallDatasourceResourceByIDOK) IsClientError() bool {
	return false
}

// IsServerError returns true when this call datasource resource by Id Ok response has a 5xx status code
func (o *CallDatasourceResourceByIDOK) IsServerError() bool {
	return false
}

// IsCode returns true when this call datasource resource by Id Ok response a status code equal to that given
func (o *CallDatasourceResourceByIDOK) IsCode(code int) bool {
	return code == 200
}

// Code gets the status code for the call datasource resource by Id Ok response
func (o *CallDatasourceResourceByIDOK) Code() int {
	return 200
}

func (o *CallDatasourceResourceByIDOK) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /datasources/{id}/resources/{datasource_proxy_route}][%d] callDatasourceResourceByIdOk %s", 200, payload)
}

func (o *CallDatasourceResourceByIDOK) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /datasources/{id}/resources/{datasource_proxy_route}][%d] callDatasourceResourceByIdOk %s", 200, payload)
}

func (o *CallDatasourceResourceByIDOK) GetPayload() *models.SuccessResponseBody {
	return o.Payload
}

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

	o.Payload = new(models.SuccessResponseBody)

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

	return nil
}

// NewCallDatasourceResourceByIDBadRequest creates a CallDatasourceResourceByIDBadRequest with default headers values
func NewCallDatasourceResourceByIDBadRequest() *CallDatasourceResourceByIDBadRequest {
	return &CallDatasourceResourceByIDBadRequest{}
}

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

BadRequestError is returned when the request is invalid and it cannot be processed.
*/
type CallDatasourceResourceByIDBadRequest struct {
	Payload *models.ErrorResponseBody
}

// IsSuccess returns true when this call datasource resource by Id bad request response has a 2xx status code
func (o *CallDatasourceResourceByIDBadRequest) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this call datasource resource by Id bad request response has a 3xx status code
func (o *CallDatasourceResourceByIDBadRequest) IsRedirect() bool {
	return false
}

// IsClientError returns true when this call datasource resource by Id bad request response has a 4xx status code
func (o *CallDatasourceResourceByIDBadRequest) IsClientError() bool {
	return true
}

// IsServerError returns true when this call datasource resource by Id bad request response has a 5xx status code
func (o *CallDatasourceResourceByIDBadRequest) IsServerError() bool {
	return false
}

// IsCode returns true when this call datasource resource by Id bad request response a status code equal to that given
func (o *CallDatasourceResourceByIDBadRequest) IsCode(code int) bool {
	return code == 400
}

// Code gets the status code for the call datasource resource by Id bad request response
func (o *CallDatasourceResourceByIDBadRequest) Code() int {
	return 400
}

func (o *CallDatasourceResourceByIDBadRequest) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /datasources/{id}/resources/{datasource_proxy_route}][%d] callDatasourceResourceByIdBadRequest %s", 400, payload)
}

func (o *CallDatasourceResourceByIDBadRequest) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /datasources/{id}/resources/{datasource_proxy_route}][%d] callDatasourceResourceByIdBadRequest %s", 400, payload)
}

func (o *CallDatasourceResourceByIDBadRequest) GetPayload() *models.ErrorResponseBody {
	return o.Payload
}

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

	o.Payload = new(models.ErrorResponseBody)

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

	return nil
}

// NewCallDatasourceResourceByIDUnauthorized creates a CallDatasourceResourceByIDUnauthorized with default headers values
func NewCallDatasourceResourceByIDUnauthorized() *CallDatasourceResourceByIDUnauthorized {
	return &CallDatasourceResourceByIDUnauthorized{}
}

/*
CallDatasourceResourceByIDUnauthorized describes a response with status code 401, with default header values.

UnauthorizedError is returned when the request is not authenticated.
*/
type CallDatasourceResourceByIDUnauthorized struct {
	Payload *models.ErrorResponseBody
}

// IsSuccess returns true when this call datasource resource by Id unauthorized response has a 2xx status code
func (o *CallDatasourceResourceByIDUnauthorized) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this call datasource resource by Id unauthorized response has a 3xx status code
func (o *CallDatasourceResourceByIDUnauthorized) IsRedirect() bool {
	return false
}

// IsClientError returns true when this call datasource resource by Id unauthorized response has a 4xx status code
func (o *CallDatasourceResourceByIDUnauthorized) IsClientError() bool {
	return true
}

// IsServerError returns true when this call datasource resource by Id unauthorized response has a 5xx status code
func (o *CallDatasourceResourceByIDUnauthorized) IsServerError() bool {
	return false
}

// IsCode returns true when this call datasource resource by Id unauthorized response a status code equal to that given
func (o *CallDatasourceResourceByIDUnauthorized) IsCode(code int) bool {
	return code == 401
}

// Code gets the status code for the call datasource resource by Id unauthorized response
func (o *CallDatasourceResourceByIDUnauthorized) Code() int {
	return 401
}

func (o *CallDatasourceResourceByIDUnauthorized) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /datasources/{id}/resources/{datasource_proxy_route}][%d] callDatasourceResourceByIdUnauthorized %s", 401, payload)
}

func (o *CallDatasourceResourceByIDUnauthorized) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /datasources/{id}/resources/{datasource_proxy_route}][%d] callDatasourceResourceByIdUnauthorized %s", 401, payload)
}

func (o *CallDatasourceResourceByIDUnauthorized) GetPayload() *models.ErrorResponseBody {
	return o.Payload
}

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

	o.Payload = new(models.ErrorResponseBody)

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

	return nil
}

// NewCallDatasourceResourceByIDForbidden creates a CallDatasourceResourceByIDForbidden with default headers values
func NewCallDatasourceResourceByIDForbidden() *CallDatasourceResourceByIDForbidden {
	return &CallDatasourceResourceByIDForbidden{}
}

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

ForbiddenError is returned if the user/token has insufficient permissions to access the requested resource.
*/
type CallDatasourceResourceByIDForbidden struct {
	Payload *models.ErrorResponseBody
}

// IsSuccess returns true when this call datasource resource by Id forbidden response has a 2xx status code
func (o *CallDatasourceResourceByIDForbidden) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this call datasource resource by Id forbidden response has a 3xx status code
func (o *CallDatasourceResourceByIDForbidden) IsRedirect() bool {
	return false
}

// IsClientError returns true when this call datasource resource by Id forbidden response has a 4xx status code
func (o *CallDatasourceResourceByIDForbidden) IsClientError() bool {
	return true
}

// IsServerError returns true when this call datasource resource by Id forbidden response has a 5xx status code
func (o *CallDatasourceResourceByIDForbidden) IsServerError() bool {
	return false
}

// IsCode returns true when this call datasource resource by Id forbidden response a status code equal to that given
func (o *CallDatasourceResourceByIDForbidden) IsCode(code int) bool {
	return code == 403
}

// Code gets the status code for the call datasource resource by Id forbidden response
func (o *CallDatasourceResourceByIDForbidden) Code() int {
	return 403
}

func (o *CallDatasourceResourceByIDForbidden) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /datasources/{id}/resources/{datasource_proxy_route}][%d] callDatasourceResourceByIdForbidden %s", 403, payload)
}

func (o *CallDatasourceResourceByIDForbidden) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /datasources/{id}/resources/{datasource_proxy_route}][%d] callDatasourceResourceByIdForbidden %s", 403, payload)
}

func (o *CallDatasourceResourceByIDForbidden) GetPayload() *models.ErrorResponseBody {
	return o.Payload
}

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

	o.Payload = new(models.ErrorResponseBody)

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

	return nil
}

// NewCallDatasourceResourceByIDNotFound creates a CallDatasourceResourceByIDNotFound with default headers values
func NewCallDatasourceResourceByIDNotFound() *CallDatasourceResourceByIDNotFound {
	return &CallDatasourceResourceByIDNotFound{}
}

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

NotFoundError is returned when the requested resource was not found.
*/
type CallDatasourceResourceByIDNotFound struct {
	Payload *models.ErrorResponseBody
}

// IsSuccess returns true when this call datasource resource by Id not found response has a 2xx status code
func (o *CallDatasourceResourceByIDNotFound) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this call datasource resource by Id not found response has a 3xx status code
func (o *CallDatasourceResourceByIDNotFound) IsRedirect() bool {
	return false
}

// IsClientError returns true when this call datasource resource by Id not found response has a 4xx status code
func (o *CallDatasourceResourceByIDNotFound) IsClientError() bool {
	return true
}

// IsServerError returns true when this call datasource resource by Id not found response has a 5xx status code
func (o *CallDatasourceResourceByIDNotFound) IsServerError() bool {
	return false
}

// IsCode returns true when this call datasource resource by Id not found response a status code equal to that given
func (o *CallDatasourceResourceByIDNotFound) IsCode(code int) bool {
	return code == 404
}

// Code gets the status code for the call datasource resource by Id not found response
func (o *CallDatasourceResourceByIDNotFound) Code() int {
	return 404
}

func (o *CallDatasourceResourceByIDNotFound) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /datasources/{id}/resources/{datasource_proxy_route}][%d] callDatasourceResourceByIdNotFound %s", 404, payload)
}

func (o *CallDatasourceResourceByIDNotFound) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /datasources/{id}/resources/{datasource_proxy_route}][%d] callDatasourceResourceByIdNotFound %s", 404, payload)
}

func (o *CallDatasourceResourceByIDNotFound) GetPayload() *models.ErrorResponseBody {
	return o.Payload
}

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

	o.Payload = new(models.ErrorResponseBody)

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

	return nil
}

// NewCallDatasourceResourceByIDInternalServerError creates a CallDatasourceResourceByIDInternalServerError with default headers values
func NewCallDatasourceResourceByIDInternalServerError() *CallDatasourceResourceByIDInternalServerError {
	return &CallDatasourceResourceByIDInternalServerError{}
}

/*
CallDatasourceResourceByIDInternalServerError describes a response with status code 500, with default header values.

InternalServerError is a general error indicating something went wrong internally.
*/
type CallDatasourceResourceByIDInternalServerError struct {
	Payload *models.ErrorResponseBody
}

// IsSuccess returns true when this call datasource resource by Id internal server error response has a 2xx status code
func (o *CallDatasourceResourceByIDInternalServerError) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this call datasource resource by Id internal server error response has a 3xx status code
func (o *CallDatasourceResourceByIDInternalServerError) IsRedirect() bool {
	return false
}

// IsClientError returns true when this call datasource resource by Id internal server error response has a 4xx status code
func (o *CallDatasourceResourceByIDInternalServerError) IsClientError() bool {
	return false
}

// IsServerError returns true when this call datasource resource by Id internal server error response has a 5xx status code
func (o *CallDatasourceResourceByIDInternalServerError) IsServerError() bool {
	return true
}

// IsCode returns true when this call datasource resource by Id internal server error response a status code equal to that given
func (o *CallDatasourceResourceByIDInternalServerError) IsCode(code int) bool {
	return code == 500
}

// Code gets the status code for the call datasource resource by Id internal server error response
func (o *CallDatasourceResourceByIDInternalServerError) Code() int {
	return 500
}

func (o *CallDatasourceResourceByIDInternalServerError) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /datasources/{id}/resources/{datasource_proxy_route}][%d] callDatasourceResourceByIdInternalServerError %s", 500, payload)
}

func (o *CallDatasourceResourceByIDInternalServerError) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /datasources/{id}/resources/{datasource_proxy_route}][%d] callDatasourceResourceByIdInternalServerError %s", 500, payload)
}

func (o *CallDatasourceResourceByIDInternalServerError) GetPayload() *models.ErrorResponseBody {
	return o.Payload
}

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

	o.Payload = new(models.ErrorResponseBody)

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

	return nil
}
