// Package v1 provides primitives to interact with the openapi HTTP API.
//
// Code generated by github.com/deepmap/oapi-codegen version v1.12.2 DO NOT EDIT.
package v1

import (
	"bytes"
	"context"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
	"net/url"
	"strings"

	"github.com/deepmap/oapi-codegen/pkg/runtime"
)

const (
	BasicAuthScopes  = "basicAuth.Scopes"
	BearerAuthScopes = "bearerAuth.Scopes"
)

// Defines values for ErrorCode.
const (
	GlobalaccountInactive                           ErrorCode = "global/account-inactive"
	GlobalinvalidApiKey                             ErrorCode = "global/invalid-api-key"
	GlobalinvalidParameters                         ErrorCode = "global/invalid-parameters"
	GlobalobjectDoesNotExist                        ErrorCode = "global/object-does-not-exist"
	Globalunknown                                   ErrorCode = "global/unknown"
	InstanceOperationslaunchfileSystemInWrongRegion ErrorCode = "instance-operations/launch/file-system-in-wrong-region"
	InstanceOperationslaunchfileSystemsNotSupported ErrorCode = "instance-operations/launch/file-systems-not-supported"
	InstanceOperationslaunchinsufficientCapacity    ErrorCode = "instance-operations/launch/insufficient-capacity"
)

// Defines values for InstanceStatus.
const (
	Active     InstanceStatus = "active"
	Booting    InstanceStatus = "booting"
	Terminated InstanceStatus = "terminated"
	Unhealthy  InstanceStatus = "unhealthy"
)

// Error defines model for error.
type Error struct {
	// Code Unique identifier for the type of error
	Code ErrorCode `json:"code"`

	// Message Detailed description of the error
	Message string `json:"message"`

	// Suggestion Suggestion of possible ways to fix the error.
	Suggestion *string `json:"suggestion"`
}

// ErrorCode Unique identifier for the type of error
type ErrorCode string

// ErrorResponseBody defines model for errorResponseBody.
type ErrorResponseBody struct {
	Error Error `json:"error"`
}

// FileSystemName Name of a file system
type FileSystemName = string

// Instance Virtual machine (VM) in Lambda Cloud
type Instance struct {
	// FileSystemNames Names of the file systems, if any, attached to the instance
	FileSystemNames []FileSystemName `json:"file_system_names"`

	// Hostname Hostname assigned to this instance, which resolves to the instance's IP.
	Hostname *string `json:"hostname"`

	// Id Unique identifier (ID) of an instance
	Id InstanceId `json:"id"`

	// InstanceType Hardware configuration and pricing of an instance type
	InstanceType *InstanceType `json:"instance_type,omitempty"`

	// Ip IPv4 address of the instance
	Ip *string `json:"ip"`

	// JupyterToken Secret token used to log into the jupyter lab server hosted on the instance.
	JupyterToken *string `json:"jupyter_token"`

	// JupyterUrl URL that opens a jupyter lab notebook on the instance.
	JupyterUrl *string `json:"jupyter_url"`

	// Name User-provided name for the instance
	Name   *InstanceName `json:"name"`
	Region *Region       `json:"region,omitempty"`

	// SshKeyNames Names of the SSH keys allowed to access the instance
	SshKeyNames []SshKeyName `json:"ssh_key_names"`

	// Status The current status of the instance
	Status InstanceStatus `json:"status"`
}

// InstanceStatus The current status of the instance
type InstanceStatus string

// InstanceId Unique identifier (ID) of an instance
type InstanceId = string

// InstanceName User-provided name for the instance
type InstanceName = string

// InstanceType Hardware configuration and pricing of an instance type
type InstanceType struct {
	// Description Long name of the instance type
	Description string `json:"description"`

	// Name Name of an instance type
	Name InstanceTypeName `json:"name"`

	// PriceCentsPerHour Price of the instance type, in US cents per hour
	PriceCentsPerHour int `json:"price_cents_per_hour"`
	Specs             struct {
		// MemoryGib Amount of RAM, in gibibytes (GiB)
		MemoryGib int `json:"memory_gib"`

		// StorageGib Amount of storage, in gibibytes (GiB).
		StorageGib int `json:"storage_gib"`

		// Vcpus Number of virtual CPUs
		Vcpus int `json:"vcpus"`
	} `json:"specs"`
}

// InstanceTypeName Name of an instance type
type InstanceTypeName = string

// Region defines model for region.
type Region struct {
	// Description Long name of a region
	Description string `json:"description"`

	// Name Short name of a region
	Name RegionName `json:"name"`
}

// RegionName Short name of a region
type RegionName = string

// SshKey Information about a stored SSH key, which can be used to access instances over SSH
type SshKey struct {
	// Id Unique identifier (ID) of an SSH key
	Id SshKeyId `json:"id"`

	// Name Name of the SSH key
	Name SshKeyName `json:"name"`

	// PrivateKey Private key for the SSH key. Only returned when generating a new key pair.
	PrivateKey *SshPrivateKey `json:"private_key"`

	// PublicKey Public key for the SSH key
	PublicKey SshPublicKey `json:"public_key"`
}

// SshKeyId Unique identifier (ID) of an SSH key
type SshKeyId = string

// SshKeyName Name of the SSH key
type SshKeyName = string

// SshPrivateKey Private key for the SSH key. Only returned when generating a new key pair.
type SshPrivateKey = string

// SshPublicKey Public key for the SSH key
type SshPublicKey = string

// AddSSHKeyAPIResponse The added or generated SSH public key. If a new key pair was generated, the response body contains a `private_key` property that *must* be saved locally. Lambda Cloud does not store private keys.
type AddSSHKeyAPIResponse struct {
	// Data Information about a stored SSH key, which can be used to access instances over SSH
	Data SshKey `json:"data"`
}

// BadRequestAPIResponse defines model for badRequest.
type BadRequestAPIResponse = ErrorResponseBody

// ForbiddenAPIResponse defines model for forbidden.
type ForbiddenAPIResponse = ErrorResponseBody

// InstanceAPIResponse defines model for instance.
type InstanceAPIResponse struct {
	// Data Virtual machine (VM) in Lambda Cloud
	Data Instance `json:"data"`
}

// InstanceTypesAPIResponse defines model for instanceTypes.
type InstanceTypesAPIResponse struct {
	// Data Dict of instance_type_name to instance_type and region availability.
	Data map[string]struct {
		// InstanceType Hardware configuration and pricing of an instance type
		InstanceType InstanceType `json:"instance_type"`

		// RegionsWithCapacityAvailable List of regions, if any, that have this instance type available
		RegionsWithCapacityAvailable []Region `json:"regions_with_capacity_available"`
	} `json:"data"`
}

// InstancesAPIResponse defines model for instances.
type InstancesAPIResponse struct {
	Data []Instance `json:"data"`
}

// InternalServerErrorAPIResponse defines model for internalServerError.
type InternalServerErrorAPIResponse = ErrorResponseBody

// LaunchAPIResponse defines model for launch.
type LaunchAPIResponse struct {
	Data struct {
		// InstanceIds The unique identifiers (IDs) of the launched instances. Note: if a quantity was specified, fewer than the requested quantity might have been launched.
		InstanceIds []InstanceId `json:"instance_ids"`
	} `json:"data"`
}

// NotFoundAPIResponse defines model for notFound.
type NotFoundAPIResponse = ErrorResponseBody

// SshKeysAPIResponse defines model for sshKeys.
type SshKeysAPIResponse struct {
	Data []SshKey `json:"data"`
}

// TerminateAPIResponse defines model for terminate.
type TerminateAPIResponse struct {
	Data struct {
		// TerminatedInstances List of instances that were terminated. Note: this list might not contain all instances requested to be terminated.
		TerminatedInstances []Instance `json:"terminated_instances"`
	} `json:"data"`
}

// UnauthorizedAPIResponse defines model for unauthorized.
type UnauthorizedAPIResponse = ErrorResponseBody

// AddSSHKey The name for the SSH key. Optionally, an existing public key can be supplied for the `public_key` property. If the `public_key` property is omitted, a new key pair is generated. The private key is returned in the response.
type AddSSHKey struct {
	// Name Name of the SSH key
	Name SshKeyName `json:"name"`

	// PublicKey Public key for the SSH key
	PublicKey *SshPublicKey `json:"public_key,omitempty"`
}

// Launch defines model for launch.
type Launch struct {
	// FileSystemNames Names of the file systems to attach to the instances. Currently, only one (if any) file system may be specified.
	FileSystemNames *[]FileSystemName `json:"file_system_names,omitempty"`

	// InstanceTypeName Name of an instance type
	InstanceTypeName InstanceTypeName `json:"instance_type_name"`

	// Name User-provided name for the instance
	Name *InstanceName `json:"name"`

	// Quantity Number of instances to launch
	Quantity *int `json:"quantity,omitempty"`

	// RegionName Short name of a region
	RegionName RegionName `json:"region_name"`

	// SshKeyNames Names of the SSH keys to allow access to the instances. Currently, exactly one SSH key must be specified.
	SshKeyNames []SshKeyName `json:"ssh_key_names"`
}

// Terminate defines model for terminate.
type Terminate struct {
	// InstanceIds The unique identifiers (IDs) of the instances to terminate
	InstanceIds []InstanceId `json:"instance_ids"`
}

// LaunchInstanceJSONBody defines parameters for LaunchInstance.
type LaunchInstanceJSONBody struct {
	// FileSystemNames Names of the file systems to attach to the instances. Currently, only one (if any) file system may be specified.
	FileSystemNames *[]FileSystemName `json:"file_system_names,omitempty"`

	// InstanceTypeName Name of an instance type
	InstanceTypeName InstanceTypeName `json:"instance_type_name"`

	// Name User-provided name for the instance
	Name *InstanceName `json:"name"`

	// Quantity Number of instances to launch
	Quantity *int `json:"quantity,omitempty"`

	// RegionName Short name of a region
	RegionName RegionName `json:"region_name"`

	// SshKeyNames Names of the SSH keys to allow access to the instances. Currently, exactly one SSH key must be specified.
	SshKeyNames []SshKeyName `json:"ssh_key_names"`
}

// TerminateInstanceJSONBody defines parameters for TerminateInstance.
type TerminateInstanceJSONBody struct {
	// InstanceIds The unique identifiers (IDs) of the instances to terminate
	InstanceIds []InstanceId `json:"instance_ids"`
}

// AddSSHKeyJSONBody defines parameters for AddSSHKey.
type AddSSHKeyJSONBody struct {
	// Name Name of the SSH key
	Name SshKeyName `json:"name"`

	// PublicKey Public key for the SSH key
	PublicKey *SshPublicKey `json:"public_key,omitempty"`
}

// LaunchInstanceJSONRequestBody defines body for LaunchInstance for application/json ContentType.
type LaunchInstanceJSONRequestBody LaunchInstanceJSONBody

// TerminateInstanceJSONRequestBody defines body for TerminateInstance for application/json ContentType.
type TerminateInstanceJSONRequestBody TerminateInstanceJSONBody

// AddSSHKeyJSONRequestBody defines body for AddSSHKey for application/json ContentType.
type AddSSHKeyJSONRequestBody AddSSHKeyJSONBody

// RequestEditorFn  is the function signature for the RequestEditor callback function
type RequestEditorFn func(ctx context.Context, req *http.Request) error

// Doer performs HTTP requests.
//
// The standard http.Client implements this interface.
type HttpRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

// Client which conforms to the OpenAPI3 specification for this service.
type Client struct {
	// The endpoint of the server conforming to this interface, with scheme,
	// https://api.deepmap.com for example. This can contain a path relative
	// to the server, such as https://api.deepmap.com/dev-test, and all the
	// paths in the swagger spec will be appended to the server.
	Server string

	// Doer for performing requests, typically a *http.Client with any
	// customized settings, such as certificate chains.
	Client HttpRequestDoer

	// A list of callbacks for modifying requests which are generated before sending over
	// the network.
	RequestEditors []RequestEditorFn
}

// ClientOption allows setting custom parameters during construction
type ClientOption func(*Client) error

// Creates a new Client, with reasonable defaults
func NewClient(server string, opts ...ClientOption) (*Client, error) {
	// create a client with sane default values
	client := Client{
		Server: server,
	}
	// mutate client and add all optional params
	for _, o := range opts {
		if err := o(&client); err != nil {
			return nil, err
		}
	}
	// ensure the server URL always has a trailing slash
	if !strings.HasSuffix(client.Server, "/") {
		client.Server += "/"
	}
	// create httpClient, if not already present
	if client.Client == nil {
		client.Client = &http.Client{}
	}
	return &client, nil
}

// WithHTTPClient allows overriding the default Doer, which is
// automatically created using http.Client. This is useful for tests.
func WithHTTPClient(doer HttpRequestDoer) ClientOption {
	return func(c *Client) error {
		c.Client = doer
		return nil
	}
}

// WithRequestEditorFn allows setting up a callback function, which will be
// called right before sending the request. This can be used to mutate the request.
func WithRequestEditorFn(fn RequestEditorFn) ClientOption {
	return func(c *Client) error {
		c.RequestEditors = append(c.RequestEditors, fn)
		return nil
	}
}

// The interface specification for the client above.
type ClientInterface interface {
	// LaunchInstance request with any body
	LaunchInstanceWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	LaunchInstance(ctx context.Context, body LaunchInstanceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// TerminateInstance request with any body
	TerminateInstanceWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	TerminateInstance(ctx context.Context, body TerminateInstanceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// InstanceTypes request
	InstanceTypes(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)

	// ListInstances request
	ListInstances(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)

	// GetInstance request
	GetInstance(ctx context.Context, id InstanceId, reqEditors ...RequestEditorFn) (*http.Response, error)

	// ListSSHKeys request
	ListSSHKeys(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)

	// AddSSHKey request with any body
	AddSSHKeyWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	AddSSHKey(ctx context.Context, body AddSSHKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
}

func (c *Client) LaunchInstanceWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
	req, err := NewLaunchInstanceRequestWithBody(c.Server, contentType, body)
	if err != nil {
		return nil, err
	}
	req = req.WithContext(ctx)
	if err := c.applyEditors(ctx, req, reqEditors); err != nil {
		return nil, err
	}
	return c.Client.Do(req)
}

func (c *Client) LaunchInstance(ctx context.Context, body LaunchInstanceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
	req, err := NewLaunchInstanceRequest(c.Server, body)
	if err != nil {
		return nil, err
	}
	req = req.WithContext(ctx)
	if err := c.applyEditors(ctx, req, reqEditors); err != nil {
		return nil, err
	}
	return c.Client.Do(req)
}

func (c *Client) TerminateInstanceWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
	req, err := NewTerminateInstanceRequestWithBody(c.Server, contentType, body)
	if err != nil {
		return nil, err
	}
	req = req.WithContext(ctx)
	if err := c.applyEditors(ctx, req, reqEditors); err != nil {
		return nil, err
	}
	return c.Client.Do(req)
}

func (c *Client) TerminateInstance(ctx context.Context, body TerminateInstanceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
	req, err := NewTerminateInstanceRequest(c.Server, body)
	if err != nil {
		return nil, err
	}
	req = req.WithContext(ctx)
	if err := c.applyEditors(ctx, req, reqEditors); err != nil {
		return nil, err
	}
	return c.Client.Do(req)
}

func (c *Client) InstanceTypes(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
	req, err := NewInstanceTypesRequest(c.Server)
	if err != nil {
		return nil, err
	}
	req = req.WithContext(ctx)
	if err := c.applyEditors(ctx, req, reqEditors); err != nil {
		return nil, err
	}
	return c.Client.Do(req)
}

func (c *Client) ListInstances(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
	req, err := NewListInstancesRequest(c.Server)
	if err != nil {
		return nil, err
	}
	req = req.WithContext(ctx)
	if err := c.applyEditors(ctx, req, reqEditors); err != nil {
		return nil, err
	}
	return c.Client.Do(req)
}

func (c *Client) GetInstance(ctx context.Context, id InstanceId, reqEditors ...RequestEditorFn) (*http.Response, error) {
	req, err := NewGetInstanceRequest(c.Server, id)
	if err != nil {
		return nil, err
	}
	req = req.WithContext(ctx)
	if err := c.applyEditors(ctx, req, reqEditors); err != nil {
		return nil, err
	}
	return c.Client.Do(req)
}

func (c *Client) ListSSHKeys(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
	req, err := NewListSSHKeysRequest(c.Server)
	if err != nil {
		return nil, err
	}
	req = req.WithContext(ctx)
	if err := c.applyEditors(ctx, req, reqEditors); err != nil {
		return nil, err
	}
	return c.Client.Do(req)
}

func (c *Client) AddSSHKeyWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
	req, err := NewAddSSHKeyRequestWithBody(c.Server, contentType, body)
	if err != nil {
		return nil, err
	}
	req = req.WithContext(ctx)
	if err := c.applyEditors(ctx, req, reqEditors); err != nil {
		return nil, err
	}
	return c.Client.Do(req)
}

func (c *Client) AddSSHKey(ctx context.Context, body AddSSHKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
	req, err := NewAddSSHKeyRequest(c.Server, body)
	if err != nil {
		return nil, err
	}
	req = req.WithContext(ctx)
	if err := c.applyEditors(ctx, req, reqEditors); err != nil {
		return nil, err
	}
	return c.Client.Do(req)
}

// NewLaunchInstanceRequest calls the generic LaunchInstance builder with application/json body
func NewLaunchInstanceRequest(server string, body LaunchInstanceJSONRequestBody) (*http.Request, error) {
	var bodyReader io.Reader
	buf, err := json.Marshal(body)
	if err != nil {
		return nil, err
	}
	bodyReader = bytes.NewReader(buf)
	return NewLaunchInstanceRequestWithBody(server, "application/json", bodyReader)
}

// NewLaunchInstanceRequestWithBody generates requests for LaunchInstance with any type of body
func NewLaunchInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
	var err error

	serverURL, err := url.Parse(server)
	if err != nil {
		return nil, err
	}

	operationPath := fmt.Sprintf("/instance-operations/launch")
	if operationPath[0] == '/' {
		operationPath = "." + operationPath
	}

	queryURL, err := serverURL.Parse(operationPath)
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest("POST", queryURL.String(), body)
	if err != nil {
		return nil, err
	}

	req.Header.Add("Content-Type", contentType)

	return req, nil
}

// NewTerminateInstanceRequest calls the generic TerminateInstance builder with application/json body
func NewTerminateInstanceRequest(server string, body TerminateInstanceJSONRequestBody) (*http.Request, error) {
	var bodyReader io.Reader
	buf, err := json.Marshal(body)
	if err != nil {
		return nil, err
	}
	bodyReader = bytes.NewReader(buf)
	return NewTerminateInstanceRequestWithBody(server, "application/json", bodyReader)
}

// NewTerminateInstanceRequestWithBody generates requests for TerminateInstance with any type of body
func NewTerminateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
	var err error

	serverURL, err := url.Parse(server)
	if err != nil {
		return nil, err
	}

	operationPath := fmt.Sprintf("/instance-operations/terminate")
	if operationPath[0] == '/' {
		operationPath = "." + operationPath
	}

	queryURL, err := serverURL.Parse(operationPath)
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest("POST", queryURL.String(), body)
	if err != nil {
		return nil, err
	}

	req.Header.Add("Content-Type", contentType)

	return req, nil
}

// NewInstanceTypesRequest generates requests for InstanceTypes
func NewInstanceTypesRequest(server string) (*http.Request, error) {
	var err error

	serverURL, err := url.Parse(server)
	if err != nil {
		return nil, err
	}

	operationPath := fmt.Sprintf("/instance-types")
	if operationPath[0] == '/' {
		operationPath = "." + operationPath
	}

	queryURL, err := serverURL.Parse(operationPath)
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest("GET", queryURL.String(), nil)
	if err != nil {
		return nil, err
	}

	return req, nil
}

// NewListInstancesRequest generates requests for ListInstances
func NewListInstancesRequest(server string) (*http.Request, error) {
	var err error

	serverURL, err := url.Parse(server)
	if err != nil {
		return nil, err
	}

	operationPath := fmt.Sprintf("/instances")
	if operationPath[0] == '/' {
		operationPath = "." + operationPath
	}

	queryURL, err := serverURL.Parse(operationPath)
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest("GET", queryURL.String(), nil)
	if err != nil {
		return nil, err
	}

	return req, nil
}

// NewGetInstanceRequest generates requests for GetInstance
func NewGetInstanceRequest(server string, id InstanceId) (*http.Request, error) {
	var err error

	var pathParam0 string

	pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id)
	if err != nil {
		return nil, err
	}

	serverURL, err := url.Parse(server)
	if err != nil {
		return nil, err
	}

	operationPath := fmt.Sprintf("/instances/%s", pathParam0)
	if operationPath[0] == '/' {
		operationPath = "." + operationPath
	}

	queryURL, err := serverURL.Parse(operationPath)
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest("GET", queryURL.String(), nil)
	if err != nil {
		return nil, err
	}

	return req, nil
}

// NewListSSHKeysRequest generates requests for ListSSHKeys
func NewListSSHKeysRequest(server string) (*http.Request, error) {
	var err error

	serverURL, err := url.Parse(server)
	if err != nil {
		return nil, err
	}

	operationPath := fmt.Sprintf("/ssh-keys")
	if operationPath[0] == '/' {
		operationPath = "." + operationPath
	}

	queryURL, err := serverURL.Parse(operationPath)
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest("GET", queryURL.String(), nil)
	if err != nil {
		return nil, err
	}

	return req, nil
}

// NewAddSSHKeyRequest calls the generic AddSSHKey builder with application/json body
func NewAddSSHKeyRequest(server string, body AddSSHKeyJSONRequestBody) (*http.Request, error) {
	var bodyReader io.Reader
	buf, err := json.Marshal(body)
	if err != nil {
		return nil, err
	}
	bodyReader = bytes.NewReader(buf)
	return NewAddSSHKeyRequestWithBody(server, "application/json", bodyReader)
}

// NewAddSSHKeyRequestWithBody generates requests for AddSSHKey with any type of body
func NewAddSSHKeyRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
	var err error

	serverURL, err := url.Parse(server)
	if err != nil {
		return nil, err
	}

	operationPath := fmt.Sprintf("/ssh-keys")
	if operationPath[0] == '/' {
		operationPath = "." + operationPath
	}

	queryURL, err := serverURL.Parse(operationPath)
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest("POST", queryURL.String(), body)
	if err != nil {
		return nil, err
	}

	req.Header.Add("Content-Type", contentType)

	return req, nil
}

func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error {
	for _, r := range c.RequestEditors {
		if err := r(ctx, req); err != nil {
			return err
		}
	}
	for _, r := range additionalEditors {
		if err := r(ctx, req); err != nil {
			return err
		}
	}
	return nil
}

// ClientWithResponses builds on ClientInterface to offer response payloads
type ClientWithResponses struct {
	ClientInterface
}

// NewClientWithResponses creates a new ClientWithResponses, which wraps
// Client with return type handling
func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) {
	client, err := NewClient(server, opts...)
	if err != nil {
		return nil, err
	}
	return &ClientWithResponses{client}, nil
}

// WithBaseURL overrides the baseURL.
func WithBaseURL(baseURL string) ClientOption {
	return func(c *Client) error {
		newBaseURL, err := url.Parse(baseURL)
		if err != nil {
			return err
		}
		c.Server = newBaseURL.String()
		return nil
	}
}

// ClientWithResponsesInterface is the interface specification for the client with responses above.
type ClientWithResponsesInterface interface {
	// LaunchInstance request with any body
	LaunchInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*LaunchInstanceResponse, error)

	LaunchInstanceWithResponse(ctx context.Context, body LaunchInstanceJSONRequestBody, reqEditors ...RequestEditorFn) (*LaunchInstanceResponse, error)

	// TerminateInstance request with any body
	TerminateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TerminateInstanceResponse, error)

	TerminateInstanceWithResponse(ctx context.Context, body TerminateInstanceJSONRequestBody, reqEditors ...RequestEditorFn) (*TerminateInstanceResponse, error)

	// InstanceTypes request
	InstanceTypesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*InstanceTypesResponse, error)

	// ListInstances request
	ListInstancesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListInstancesResponse, error)

	// GetInstance request
	GetInstanceWithResponse(ctx context.Context, id InstanceId, reqEditors ...RequestEditorFn) (*GetInstanceResponse, error)

	// ListSSHKeys request
	ListSSHKeysWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListSSHKeysResponse, error)

	// AddSSHKey request with any body
	AddSSHKeyWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AddSSHKeyResponse, error)

	AddSSHKeyWithResponse(ctx context.Context, body AddSSHKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*AddSSHKeyResponse, error)
}

type LaunchInstanceResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *struct {
		Data struct {
			// InstanceIds The unique identifiers (IDs) of the launched instances. Note: if a quantity was specified, fewer than the requested quantity might have been launched.
			InstanceIds []InstanceId `json:"instance_ids"`
		} `json:"data"`
	}
	JSON400 *ErrorResponseBody
	JSON401 *ErrorResponseBody
	JSON403 *ErrorResponseBody
	JSON404 *ErrorResponseBody
	JSON500 *ErrorResponseBody
}

// Status returns HTTPResponse.Status
func (r LaunchInstanceResponse) Status() string {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.Status
	}
	return http.StatusText(0)
}

// StatusCode returns HTTPResponse.StatusCode
func (r LaunchInstanceResponse) StatusCode() int {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.StatusCode
	}
	return 0
}

type TerminateInstanceResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *struct {
		Data struct {
			// TerminatedInstances List of instances that were terminated. Note: this list might not contain all instances requested to be terminated.
			TerminatedInstances []Instance `json:"terminated_instances"`
		} `json:"data"`
	}
	JSON400 *ErrorResponseBody
	JSON401 *ErrorResponseBody
	JSON403 *ErrorResponseBody
	JSON404 *ErrorResponseBody
	JSON500 *ErrorResponseBody
}

// Status returns HTTPResponse.Status
func (r TerminateInstanceResponse) Status() string {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.Status
	}
	return http.StatusText(0)
}

// StatusCode returns HTTPResponse.StatusCode
func (r TerminateInstanceResponse) StatusCode() int {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.StatusCode
	}
	return 0
}

type InstanceTypesResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *struct {
		// Data Dict of instance_type_name to instance_type and region availability.
		Data map[string]struct {
			// InstanceType Hardware configuration and pricing of an instance type
			InstanceType InstanceType `json:"instance_type"`

			// RegionsWithCapacityAvailable List of regions, if any, that have this instance type available
			RegionsWithCapacityAvailable []Region `json:"regions_with_capacity_available"`
		} `json:"data"`
	}
	JSON401 *ErrorResponseBody
	JSON403 *ErrorResponseBody
}

// Status returns HTTPResponse.Status
func (r InstanceTypesResponse) Status() string {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.Status
	}
	return http.StatusText(0)
}

// StatusCode returns HTTPResponse.StatusCode
func (r InstanceTypesResponse) StatusCode() int {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.StatusCode
	}
	return 0
}

type ListInstancesResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *struct {
		Data []Instance `json:"data"`
	}
	JSON401 *ErrorResponseBody
	JSON403 *ErrorResponseBody
}

// Status returns HTTPResponse.Status
func (r ListInstancesResponse) Status() string {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.Status
	}
	return http.StatusText(0)
}

// StatusCode returns HTTPResponse.StatusCode
func (r ListInstancesResponse) StatusCode() int {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.StatusCode
	}
	return 0
}

type GetInstanceResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *struct {
		// Data Virtual machine (VM) in Lambda Cloud
		Data Instance `json:"data"`
	}
	JSON401 *ErrorResponseBody
	JSON403 *ErrorResponseBody
	JSON404 *ErrorResponseBody
}

// Status returns HTTPResponse.Status
func (r GetInstanceResponse) Status() string {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.Status
	}
	return http.StatusText(0)
}

// StatusCode returns HTTPResponse.StatusCode
func (r GetInstanceResponse) StatusCode() int {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.StatusCode
	}
	return 0
}

type ListSSHKeysResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *struct {
		Data []SshKey `json:"data"`
	}
	JSON401 *ErrorResponseBody
	JSON403 *ErrorResponseBody
}

// Status returns HTTPResponse.Status
func (r ListSSHKeysResponse) Status() string {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.Status
	}
	return http.StatusText(0)
}

// StatusCode returns HTTPResponse.StatusCode
func (r ListSSHKeysResponse) StatusCode() int {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.StatusCode
	}
	return 0
}

type AddSSHKeyResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *struct {
		// Data Information about a stored SSH key, which can be used to access instances over SSH
		Data SshKey `json:"data"`
	}
	JSON400 *ErrorResponseBody
	JSON401 *ErrorResponseBody
	JSON403 *ErrorResponseBody
}

// Status returns HTTPResponse.Status
func (r AddSSHKeyResponse) Status() string {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.Status
	}
	return http.StatusText(0)
}

// StatusCode returns HTTPResponse.StatusCode
func (r AddSSHKeyResponse) StatusCode() int {
	if r.HTTPResponse != nil {
		return r.HTTPResponse.StatusCode
	}
	return 0
}

// LaunchInstanceWithBodyWithResponse request with arbitrary body returning *LaunchInstanceResponse
func (c *ClientWithResponses) LaunchInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*LaunchInstanceResponse, error) {
	rsp, err := c.LaunchInstanceWithBody(ctx, contentType, body, reqEditors...)
	if err != nil {
		return nil, err
	}
	return ParseLaunchInstanceResponse(rsp)
}

func (c *ClientWithResponses) LaunchInstanceWithResponse(ctx context.Context, body LaunchInstanceJSONRequestBody, reqEditors ...RequestEditorFn) (*LaunchInstanceResponse, error) {
	rsp, err := c.LaunchInstance(ctx, body, reqEditors...)
	if err != nil {
		return nil, err
	}
	return ParseLaunchInstanceResponse(rsp)
}

// TerminateInstanceWithBodyWithResponse request with arbitrary body returning *TerminateInstanceResponse
func (c *ClientWithResponses) TerminateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TerminateInstanceResponse, error) {
	rsp, err := c.TerminateInstanceWithBody(ctx, contentType, body, reqEditors...)
	if err != nil {
		return nil, err
	}
	return ParseTerminateInstanceResponse(rsp)
}

func (c *ClientWithResponses) TerminateInstanceWithResponse(ctx context.Context, body TerminateInstanceJSONRequestBody, reqEditors ...RequestEditorFn) (*TerminateInstanceResponse, error) {
	rsp, err := c.TerminateInstance(ctx, body, reqEditors...)
	if err != nil {
		return nil, err
	}
	return ParseTerminateInstanceResponse(rsp)
}

// InstanceTypesWithResponse request returning *InstanceTypesResponse
func (c *ClientWithResponses) InstanceTypesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*InstanceTypesResponse, error) {
	rsp, err := c.InstanceTypes(ctx, reqEditors...)
	if err != nil {
		return nil, err
	}
	return ParseInstanceTypesResponse(rsp)
}

// ListInstancesWithResponse request returning *ListInstancesResponse
func (c *ClientWithResponses) ListInstancesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListInstancesResponse, error) {
	rsp, err := c.ListInstances(ctx, reqEditors...)
	if err != nil {
		return nil, err
	}
	return ParseListInstancesResponse(rsp)
}

// GetInstanceWithResponse request returning *GetInstanceResponse
func (c *ClientWithResponses) GetInstanceWithResponse(ctx context.Context, id InstanceId, reqEditors ...RequestEditorFn) (*GetInstanceResponse, error) {
	rsp, err := c.GetInstance(ctx, id, reqEditors...)
	if err != nil {
		return nil, err
	}
	return ParseGetInstanceResponse(rsp)
}

// ListSSHKeysWithResponse request returning *ListSSHKeysResponse
func (c *ClientWithResponses) ListSSHKeysWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListSSHKeysResponse, error) {
	rsp, err := c.ListSSHKeys(ctx, reqEditors...)
	if err != nil {
		return nil, err
	}
	return ParseListSSHKeysResponse(rsp)
}

// AddSSHKeyWithBodyWithResponse request with arbitrary body returning *AddSSHKeyResponse
func (c *ClientWithResponses) AddSSHKeyWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AddSSHKeyResponse, error) {
	rsp, err := c.AddSSHKeyWithBody(ctx, contentType, body, reqEditors...)
	if err != nil {
		return nil, err
	}
	return ParseAddSSHKeyResponse(rsp)
}

func (c *ClientWithResponses) AddSSHKeyWithResponse(ctx context.Context, body AddSSHKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*AddSSHKeyResponse, error) {
	rsp, err := c.AddSSHKey(ctx, body, reqEditors...)
	if err != nil {
		return nil, err
	}
	return ParseAddSSHKeyResponse(rsp)
}

// ParseLaunchInstanceResponse parses an HTTP response from a LaunchInstanceWithResponse call
func ParseLaunchInstanceResponse(rsp *http.Response) (*LaunchInstanceResponse, error) {
	bodyBytes, err := io.ReadAll(rsp.Body)
	defer func() { _ = rsp.Body.Close() }()
	if err != nil {
		return nil, err
	}

	response := &LaunchInstanceResponse{
		Body:         bodyBytes,
		HTTPResponse: rsp,
	}

	switch {
	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
		var dest struct {
			Data struct {
				// InstanceIds The unique identifiers (IDs) of the launched instances. Note: if a quantity was specified, fewer than the requested quantity might have been launched.
				InstanceIds []InstanceId `json:"instance_ids"`
			} `json:"data"`
		}
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON200 = &dest

	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400:
		var dest ErrorResponseBody
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON400 = &dest

	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
		var dest ErrorResponseBody
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON401 = &dest

	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
		var dest ErrorResponseBody
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON403 = &dest

	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
		var dest ErrorResponseBody
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON404 = &dest

	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
		var dest ErrorResponseBody
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON500 = &dest

	}

	return response, nil
}

// ParseTerminateInstanceResponse parses an HTTP response from a TerminateInstanceWithResponse call
func ParseTerminateInstanceResponse(rsp *http.Response) (*TerminateInstanceResponse, error) {
	bodyBytes, err := io.ReadAll(rsp.Body)
	defer func() { _ = rsp.Body.Close() }()
	if err != nil {
		return nil, err
	}

	response := &TerminateInstanceResponse{
		Body:         bodyBytes,
		HTTPResponse: rsp,
	}

	switch {
	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
		var dest struct {
			Data struct {
				// TerminatedInstances List of instances that were terminated. Note: this list might not contain all instances requested to be terminated.
				TerminatedInstances []Instance `json:"terminated_instances"`
			} `json:"data"`
		}
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON200 = &dest

	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400:
		var dest ErrorResponseBody
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON400 = &dest

	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
		var dest ErrorResponseBody
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON401 = &dest

	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
		var dest ErrorResponseBody
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON403 = &dest

	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
		var dest ErrorResponseBody
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON404 = &dest

	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
		var dest ErrorResponseBody
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON500 = &dest

	}

	return response, nil
}

// ParseInstanceTypesResponse parses an HTTP response from a InstanceTypesWithResponse call
func ParseInstanceTypesResponse(rsp *http.Response) (*InstanceTypesResponse, error) {
	bodyBytes, err := io.ReadAll(rsp.Body)
	defer func() { _ = rsp.Body.Close() }()
	if err != nil {
		return nil, err
	}

	response := &InstanceTypesResponse{
		Body:         bodyBytes,
		HTTPResponse: rsp,
	}

	switch {
	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
		var dest struct {
			// Data Dict of instance_type_name to instance_type and region availability.
			Data map[string]struct {
				// InstanceType Hardware configuration and pricing of an instance type
				InstanceType InstanceType `json:"instance_type"`

				// RegionsWithCapacityAvailable List of regions, if any, that have this instance type available
				RegionsWithCapacityAvailable []Region `json:"regions_with_capacity_available"`
			} `json:"data"`
		}
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON200 = &dest

	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
		var dest ErrorResponseBody
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON401 = &dest

	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
		var dest ErrorResponseBody
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON403 = &dest

	}

	return response, nil
}

// ParseListInstancesResponse parses an HTTP response from a ListInstancesWithResponse call
func ParseListInstancesResponse(rsp *http.Response) (*ListInstancesResponse, error) {
	bodyBytes, err := io.ReadAll(rsp.Body)
	defer func() { _ = rsp.Body.Close() }()
	if err != nil {
		return nil, err
	}

	response := &ListInstancesResponse{
		Body:         bodyBytes,
		HTTPResponse: rsp,
	}

	switch {
	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
		var dest struct {
			Data []Instance `json:"data"`
		}
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON200 = &dest

	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
		var dest ErrorResponseBody
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON401 = &dest

	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
		var dest ErrorResponseBody
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON403 = &dest

	}

	return response, nil
}

// ParseGetInstanceResponse parses an HTTP response from a GetInstanceWithResponse call
func ParseGetInstanceResponse(rsp *http.Response) (*GetInstanceResponse, error) {
	bodyBytes, err := io.ReadAll(rsp.Body)
	defer func() { _ = rsp.Body.Close() }()
	if err != nil {
		return nil, err
	}

	response := &GetInstanceResponse{
		Body:         bodyBytes,
		HTTPResponse: rsp,
	}

	switch {
	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
		var dest struct {
			// Data Virtual machine (VM) in Lambda Cloud
			Data Instance `json:"data"`
		}
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON200 = &dest

	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
		var dest ErrorResponseBody
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON401 = &dest

	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
		var dest ErrorResponseBody
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON403 = &dest

	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
		var dest ErrorResponseBody
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON404 = &dest

	}

	return response, nil
}

// ParseListSSHKeysResponse parses an HTTP response from a ListSSHKeysWithResponse call
func ParseListSSHKeysResponse(rsp *http.Response) (*ListSSHKeysResponse, error) {
	bodyBytes, err := io.ReadAll(rsp.Body)
	defer func() { _ = rsp.Body.Close() }()
	if err != nil {
		return nil, err
	}

	response := &ListSSHKeysResponse{
		Body:         bodyBytes,
		HTTPResponse: rsp,
	}

	switch {
	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
		var dest struct {
			Data []SshKey `json:"data"`
		}
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON200 = &dest

	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
		var dest ErrorResponseBody
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON401 = &dest

	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
		var dest ErrorResponseBody
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON403 = &dest

	}

	return response, nil
}

// ParseAddSSHKeyResponse parses an HTTP response from a AddSSHKeyWithResponse call
func ParseAddSSHKeyResponse(rsp *http.Response) (*AddSSHKeyResponse, error) {
	bodyBytes, err := io.ReadAll(rsp.Body)
	defer func() { _ = rsp.Body.Close() }()
	if err != nil {
		return nil, err
	}

	response := &AddSSHKeyResponse{
		Body:         bodyBytes,
		HTTPResponse: rsp,
	}

	switch {
	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
		var dest struct {
			// Data Information about a stored SSH key, which can be used to access instances over SSH
			Data SshKey `json:"data"`
		}
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON200 = &dest

	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400:
		var dest ErrorResponseBody
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON400 = &dest

	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
		var dest ErrorResponseBody
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON401 = &dest

	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
		var dest ErrorResponseBody
		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
			return nil, err
		}
		response.JSON403 = &dest

	}

	return response, nil
}
