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

package package_operations

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

	"src.opensuse.org/autogits/common/gitea-generated/models"
)

// ListPackagesReader is a Reader for the ListPackages structure.
type ListPackagesReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *ListPackagesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewListPackagesOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 404:
		result := NewListPackagesNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[GET /packages/{owner}] listPackages", response, response.Code())
	}
}

// NewListPackagesOK creates a ListPackagesOK with default headers values
func NewListPackagesOK() *ListPackagesOK {
	return &ListPackagesOK{}
}

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

PackageList
*/
type ListPackagesOK struct {
	Payload []*models.Package
}

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

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

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

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

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

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

func (o *ListPackagesOK) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /packages/{owner}][%d] listPackagesOK %s", 200, payload)
}

func (o *ListPackagesOK) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /packages/{owner}][%d] listPackagesOK %s", 200, payload)
}

func (o *ListPackagesOK) GetPayload() []*models.Package {
	return o.Payload
}

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

// NewListPackagesNotFound creates a ListPackagesNotFound with default headers values
func NewListPackagesNotFound() *ListPackagesNotFound {
	return &ListPackagesNotFound{}
}

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

APINotFound is a not found empty response
*/
type ListPackagesNotFound struct {
}

// IsSuccess returns true when this list packages not found response has a 2xx status code
func (o *ListPackagesNotFound) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this list packages not found response has a 3xx status code
func (o *ListPackagesNotFound) IsRedirect() bool {
	return false
}

// IsClientError returns true when this list packages not found response has a 4xx status code
func (o *ListPackagesNotFound) IsClientError() bool {
	return true
}

// IsServerError returns true when this list packages not found response has a 5xx status code
func (o *ListPackagesNotFound) IsServerError() bool {
	return false
}

// IsCode returns true when this list packages not found response a status code equal to that given
func (o *ListPackagesNotFound) IsCode(code int) bool {
	return code == 404
}

// Code gets the status code for the list packages not found response
func (o *ListPackagesNotFound) Code() int {
	return 404
}

func (o *ListPackagesNotFound) Error() string {
	return fmt.Sprintf("[GET /packages/{owner}][%d] listPackagesNotFound", 404)
}

func (o *ListPackagesNotFound) String() string {
	return fmt.Sprintf("[GET /packages/{owner}][%d] listPackagesNotFound", 404)
}

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

	return nil
}
