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

package admin

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

import (
	"context"
	"encoding/json"
	"fmt"
	"io"

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

// CreateFrontendReader is a Reader for the CreateFrontend structure.
type CreateFrontendReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *CreateFrontendReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 201:
		result := NewCreateFrontendCreated()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 400:
		result := NewCreateFrontendBadRequest()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 401:
		result := NewCreateFrontendUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewCreateFrontendNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 500:
		result := NewCreateFrontendInternalServerError()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[POST /frontend] createFrontend", response, response.Code())
	}
}

// NewCreateFrontendCreated creates a CreateFrontendCreated with default headers values
func NewCreateFrontendCreated() *CreateFrontendCreated {
	return &CreateFrontendCreated{}
}

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

frontend created
*/
type CreateFrontendCreated struct {
	Payload *CreateFrontendCreatedBody
}

// IsSuccess returns true when this create frontend created response has a 2xx status code
func (o *CreateFrontendCreated) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this create frontend created response has a 3xx status code
func (o *CreateFrontendCreated) IsRedirect() bool {
	return false
}

// IsClientError returns true when this create frontend created response has a 4xx status code
func (o *CreateFrontendCreated) IsClientError() bool {
	return false
}

// IsServerError returns true when this create frontend created response has a 5xx status code
func (o *CreateFrontendCreated) IsServerError() bool {
	return false
}

// IsCode returns true when this create frontend created response a status code equal to that given
func (o *CreateFrontendCreated) IsCode(code int) bool {
	return code == 201
}

// Code gets the status code for the create frontend created response
func (o *CreateFrontendCreated) Code() int {
	return 201
}

func (o *CreateFrontendCreated) Error() string {
	return fmt.Sprintf("[POST /frontend][%d] createFrontendCreated  %+v", 201, o.Payload)
}

func (o *CreateFrontendCreated) String() string {
	return fmt.Sprintf("[POST /frontend][%d] createFrontendCreated  %+v", 201, o.Payload)
}

func (o *CreateFrontendCreated) GetPayload() *CreateFrontendCreatedBody {
	return o.Payload
}

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

	o.Payload = new(CreateFrontendCreatedBody)

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

	return nil
}

// NewCreateFrontendBadRequest creates a CreateFrontendBadRequest with default headers values
func NewCreateFrontendBadRequest() *CreateFrontendBadRequest {
	return &CreateFrontendBadRequest{}
}

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

bad request
*/
type CreateFrontendBadRequest struct {
}

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

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

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

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

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

// Code gets the status code for the create frontend bad request response
func (o *CreateFrontendBadRequest) Code() int {
	return 400
}

func (o *CreateFrontendBadRequest) Error() string {
	return fmt.Sprintf("[POST /frontend][%d] createFrontendBadRequest ", 400)
}

func (o *CreateFrontendBadRequest) String() string {
	return fmt.Sprintf("[POST /frontend][%d] createFrontendBadRequest ", 400)
}

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

	return nil
}

// NewCreateFrontendUnauthorized creates a CreateFrontendUnauthorized with default headers values
func NewCreateFrontendUnauthorized() *CreateFrontendUnauthorized {
	return &CreateFrontendUnauthorized{}
}

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

unauthorized
*/
type CreateFrontendUnauthorized struct {
}

// IsSuccess returns true when this create frontend unauthorized response has a 2xx status code
func (o *CreateFrontendUnauthorized) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this create frontend unauthorized response has a 3xx status code
func (o *CreateFrontendUnauthorized) IsRedirect() bool {
	return false
}

// IsClientError returns true when this create frontend unauthorized response has a 4xx status code
func (o *CreateFrontendUnauthorized) IsClientError() bool {
	return true
}

// IsServerError returns true when this create frontend unauthorized response has a 5xx status code
func (o *CreateFrontendUnauthorized) IsServerError() bool {
	return false
}

// IsCode returns true when this create frontend unauthorized response a status code equal to that given
func (o *CreateFrontendUnauthorized) IsCode(code int) bool {
	return code == 401
}

// Code gets the status code for the create frontend unauthorized response
func (o *CreateFrontendUnauthorized) Code() int {
	return 401
}

func (o *CreateFrontendUnauthorized) Error() string {
	return fmt.Sprintf("[POST /frontend][%d] createFrontendUnauthorized ", 401)
}

func (o *CreateFrontendUnauthorized) String() string {
	return fmt.Sprintf("[POST /frontend][%d] createFrontendUnauthorized ", 401)
}

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

	return nil
}

// NewCreateFrontendNotFound creates a CreateFrontendNotFound with default headers values
func NewCreateFrontendNotFound() *CreateFrontendNotFound {
	return &CreateFrontendNotFound{}
}

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

not found
*/
type CreateFrontendNotFound struct {
}

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

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

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

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

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

// Code gets the status code for the create frontend not found response
func (o *CreateFrontendNotFound) Code() int {
	return 404
}

func (o *CreateFrontendNotFound) Error() string {
	return fmt.Sprintf("[POST /frontend][%d] createFrontendNotFound ", 404)
}

func (o *CreateFrontendNotFound) String() string {
	return fmt.Sprintf("[POST /frontend][%d] createFrontendNotFound ", 404)
}

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

	return nil
}

// NewCreateFrontendInternalServerError creates a CreateFrontendInternalServerError with default headers values
func NewCreateFrontendInternalServerError() *CreateFrontendInternalServerError {
	return &CreateFrontendInternalServerError{}
}

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

internal server error
*/
type CreateFrontendInternalServerError struct {
}

// IsSuccess returns true when this create frontend internal server error response has a 2xx status code
func (o *CreateFrontendInternalServerError) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this create frontend internal server error response has a 3xx status code
func (o *CreateFrontendInternalServerError) IsRedirect() bool {
	return false
}

// IsClientError returns true when this create frontend internal server error response has a 4xx status code
func (o *CreateFrontendInternalServerError) IsClientError() bool {
	return false
}

// IsServerError returns true when this create frontend internal server error response has a 5xx status code
func (o *CreateFrontendInternalServerError) IsServerError() bool {
	return true
}

// IsCode returns true when this create frontend internal server error response a status code equal to that given
func (o *CreateFrontendInternalServerError) IsCode(code int) bool {
	return code == 500
}

// Code gets the status code for the create frontend internal server error response
func (o *CreateFrontendInternalServerError) Code() int {
	return 500
}

func (o *CreateFrontendInternalServerError) Error() string {
	return fmt.Sprintf("[POST /frontend][%d] createFrontendInternalServerError ", 500)
}

func (o *CreateFrontendInternalServerError) String() string {
	return fmt.Sprintf("[POST /frontend][%d] createFrontendInternalServerError ", 500)
}

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

	return nil
}

/*
CreateFrontendBody create frontend body
swagger:model CreateFrontendBody
*/
type CreateFrontendBody struct {

	// permission mode
	// Enum: [open closed]
	PermissionMode string `json:"permissionMode,omitempty"`

	// public name
	PublicName string `json:"public_name,omitempty"`

	// url template
	URLTemplate string `json:"url_template,omitempty"`

	// z Id
	ZID string `json:"zId,omitempty"`
}

// Validate validates this create frontend body
func (o *CreateFrontendBody) Validate(formats strfmt.Registry) error {
	var res []error

	if err := o.validatePermissionMode(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

var createFrontendBodyTypePermissionModePropEnum []interface{}

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["open","closed"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		createFrontendBodyTypePermissionModePropEnum = append(createFrontendBodyTypePermissionModePropEnum, v)
	}
}

const (

	// CreateFrontendBodyPermissionModeOpen captures enum value "open"
	CreateFrontendBodyPermissionModeOpen string = "open"

	// CreateFrontendBodyPermissionModeClosed captures enum value "closed"
	CreateFrontendBodyPermissionModeClosed string = "closed"
)

// prop value enum
func (o *CreateFrontendBody) validatePermissionModeEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, createFrontendBodyTypePermissionModePropEnum, true); err != nil {
		return err
	}
	return nil
}

func (o *CreateFrontendBody) validatePermissionMode(formats strfmt.Registry) error {
	if swag.IsZero(o.PermissionMode) { // not required
		return nil
	}

	// value enum
	if err := o.validatePermissionModeEnum("body"+"."+"permissionMode", "body", o.PermissionMode); err != nil {
		return err
	}

	return nil
}

// ContextValidate validates this create frontend body based on context it is used
func (o *CreateFrontendBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

// MarshalBinary interface implementation
func (o *CreateFrontendBody) MarshalBinary() ([]byte, error) {
	if o == nil {
		return nil, nil
	}
	return swag.WriteJSON(o)
}

// UnmarshalBinary interface implementation
func (o *CreateFrontendBody) UnmarshalBinary(b []byte) error {
	var res CreateFrontendBody
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*o = res
	return nil
}

/*
CreateFrontendCreatedBody create frontend created body
swagger:model CreateFrontendCreatedBody
*/
type CreateFrontendCreatedBody struct {

	// token
	Token string `json:"token,omitempty"`
}

// Validate validates this create frontend created body
func (o *CreateFrontendCreatedBody) Validate(formats strfmt.Registry) error {
	return nil
}

// ContextValidate validates this create frontend created body based on context it is used
func (o *CreateFrontendCreatedBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

// MarshalBinary interface implementation
func (o *CreateFrontendCreatedBody) MarshalBinary() ([]byte, error) {
	if o == nil {
		return nil, nil
	}
	return swag.WriteJSON(o)
}

// UnmarshalBinary interface implementation
func (o *CreateFrontendCreatedBody) UnmarshalBinary(b []byte) error {
	var res CreateFrontendCreatedBody
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*o = res
	return nil
}
