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

package provisioning

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

// PostMuteTimingReader is a Reader for the PostMuteTiming structure.
type PostMuteTimingReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *PostMuteTimingReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 201:
		result := NewPostMuteTimingCreated()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 400:
		result := NewPostMuteTimingBadRequest()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[POST /v1/provisioning/mute-timings] PostMuteTiming", response, response.Code())
	}
}

// NewPostMuteTimingCreated creates a PostMuteTimingCreated with default headers values
func NewPostMuteTimingCreated() *PostMuteTimingCreated {
	return &PostMuteTimingCreated{}
}

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

MuteTimeInterval
*/
type PostMuteTimingCreated struct {
	Payload *models.MuteTimeInterval
}

// IsSuccess returns true when this post mute timing created response has a 2xx status code
func (o *PostMuteTimingCreated) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this post mute timing created response has a 3xx status code
func (o *PostMuteTimingCreated) IsRedirect() bool {
	return false
}

// IsClientError returns true when this post mute timing created response has a 4xx status code
func (o *PostMuteTimingCreated) IsClientError() bool {
	return false
}

// IsServerError returns true when this post mute timing created response has a 5xx status code
func (o *PostMuteTimingCreated) IsServerError() bool {
	return false
}

// IsCode returns true when this post mute timing created response a status code equal to that given
func (o *PostMuteTimingCreated) IsCode(code int) bool {
	return code == 201
}

// Code gets the status code for the post mute timing created response
func (o *PostMuteTimingCreated) Code() int {
	return 201
}

func (o *PostMuteTimingCreated) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/provisioning/mute-timings][%d] postMuteTimingCreated %s", 201, payload)
}

func (o *PostMuteTimingCreated) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/provisioning/mute-timings][%d] postMuteTimingCreated %s", 201, payload)
}

func (o *PostMuteTimingCreated) GetPayload() *models.MuteTimeInterval {
	return o.Payload
}

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

	o.Payload = new(models.MuteTimeInterval)

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

	return nil
}

// NewPostMuteTimingBadRequest creates a PostMuteTimingBadRequest with default headers values
func NewPostMuteTimingBadRequest() *PostMuteTimingBadRequest {
	return &PostMuteTimingBadRequest{}
}

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

ValidationError
*/
type PostMuteTimingBadRequest struct {
	Payload *models.ValidationError
}

// IsSuccess returns true when this post mute timing bad request response has a 2xx status code
func (o *PostMuteTimingBadRequest) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this post mute timing bad request response has a 3xx status code
func (o *PostMuteTimingBadRequest) IsRedirect() bool {
	return false
}

// IsClientError returns true when this post mute timing bad request response has a 4xx status code
func (o *PostMuteTimingBadRequest) IsClientError() bool {
	return true
}

// IsServerError returns true when this post mute timing bad request response has a 5xx status code
func (o *PostMuteTimingBadRequest) IsServerError() bool {
	return false
}

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

// Code gets the status code for the post mute timing bad request response
func (o *PostMuteTimingBadRequest) Code() int {
	return 400
}

func (o *PostMuteTimingBadRequest) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/provisioning/mute-timings][%d] postMuteTimingBadRequest %s", 400, payload)
}

func (o *PostMuteTimingBadRequest) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/provisioning/mute-timings][%d] postMuteTimingBadRequest %s", 400, payload)
}

func (o *PostMuteTimingBadRequest) GetPayload() *models.ValidationError {
	return o.Payload
}

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

	o.Payload = new(models.ValidationError)

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

	return nil
}
