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

package lm

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"fmt"
	"io"

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

	"github.com/logicmonitor/lm-sdk-go/models"
)

// GetEventSourceListReader is a Reader for the GetEventSourceList structure.
type GetEventSourceListReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *GetEventSourceListReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewGetEventSourceListOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 429:
		result := NewGetEventSourceListTooManyRequests()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		result := NewGetEventSourceListDefault(response.Code())
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		if response.Code()/100 == 2 {
			return result, nil
		}
		return nil, result
	}
}

// NewGetEventSourceListOK creates a GetEventSourceListOK with default headers values
func NewGetEventSourceListOK() *GetEventSourceListOK {
	return &GetEventSourceListOK{}
}

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

successful operation
*/
type GetEventSourceListOK struct {
	Payload *models.EventSourcePaginationResponse
}

func (o *GetEventSourceListOK) Error() string {
	return fmt.Sprintf("[GET /setting/eventsources][%d] getEventSourceListOK  %+v", 200, o.Payload)
}
func (o *GetEventSourceListOK) GetPayload() *models.EventSourcePaginationResponse {
	return o.Payload
}

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

	o.Payload = new(models.EventSourcePaginationResponse)

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

	return nil
}

// NewGetEventSourceListTooManyRequests creates a GetEventSourceListTooManyRequests with default headers values
func NewGetEventSourceListTooManyRequests() *GetEventSourceListTooManyRequests {
	return &GetEventSourceListTooManyRequests{}
}

/* GetEventSourceListTooManyRequests describes a response with status code 429, with default header values.

Too Many Requests
*/
type GetEventSourceListTooManyRequests struct {

	/* Request limit per X-Rate-Limit-Window
	 */
	XRateLimitLimit int64

	/* The number of requests left for the time window
	 */
	XRateLimitRemaining int64

	/* The rolling time window length with the unit of second
	 */
	XRateLimitWindow int64
}

func (o *GetEventSourceListTooManyRequests) Error() string {
	return fmt.Sprintf("[GET /setting/eventsources][%d] getEventSourceListTooManyRequests ", 429)
}

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

	// hydrates response header x-rate-limit-limit
	hdrXRateLimitLimit := response.GetHeader("x-rate-limit-limit")

	if hdrXRateLimitLimit != "" {
		valxRateLimitLimit, err := swag.ConvertInt64(hdrXRateLimitLimit)
		if err != nil {
			return errors.InvalidType("x-rate-limit-limit", "header", "int64", hdrXRateLimitLimit)
		}
		o.XRateLimitLimit = valxRateLimitLimit
	}

	// hydrates response header x-rate-limit-remaining
	hdrXRateLimitRemaining := response.GetHeader("x-rate-limit-remaining")

	if hdrXRateLimitRemaining != "" {
		valxRateLimitRemaining, err := swag.ConvertInt64(hdrXRateLimitRemaining)
		if err != nil {
			return errors.InvalidType("x-rate-limit-remaining", "header", "int64", hdrXRateLimitRemaining)
		}
		o.XRateLimitRemaining = valxRateLimitRemaining
	}

	// hydrates response header x-rate-limit-window
	hdrXRateLimitWindow := response.GetHeader("x-rate-limit-window")

	if hdrXRateLimitWindow != "" {
		valxRateLimitWindow, err := swag.ConvertInt64(hdrXRateLimitWindow)
		if err != nil {
			return errors.InvalidType("x-rate-limit-window", "header", "int64", hdrXRateLimitWindow)
		}
		o.XRateLimitWindow = valxRateLimitWindow
	}

	return nil
}

// NewGetEventSourceListDefault creates a GetEventSourceListDefault with default headers values
func NewGetEventSourceListDefault(code int) *GetEventSourceListDefault {
	return &GetEventSourceListDefault{
		_statusCode: code,
	}
}

/* GetEventSourceListDefault describes a response with status code -1, with default header values.

Error
*/
type GetEventSourceListDefault struct {
	_statusCode int

	Payload *models.ErrorResponse
}

// Code gets the status code for the get event source list default response
func (o *GetEventSourceListDefault) Code() int {
	return o._statusCode
}

func (o *GetEventSourceListDefault) Error() string {
	return fmt.Sprintf("[GET /setting/eventsources][%d] getEventSourceList default  %+v", o._statusCode, o.Payload)
}
func (o *GetEventSourceListDefault) GetPayload() *models.ErrorResponse {
	return o.Payload
}

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

	o.Payload = new(models.ErrorResponse)

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

	return nil
}
