internal

package
v0.0.0-...-3fcc050 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ContextServerIndex uses a server configuration from the index.
	ContextServerIndex = contextKey("serverIndex")

	// ContextOperationServerIndices uses a server configuration from the index mapping.
	ContextOperationServerIndices = contextKey("serverOperationIndices")

	// ContextServerVariables overrides a server configuration variables.
	ContextServerVariables = contextKey("serverVariables")

	// ContextOperationServerVariables overrides a server configuration variables using operation specific values.
	ContextOperationServerVariables = contextKey("serverOperationVariables")
)

Functions

func CacheExpires

func CacheExpires(r *http.Response) time.Time

CacheExpires helper function to determine remaining time before repeating a request.

func FormatErrorMessage

func FormatErrorMessage(status string, v interface{}) string

format error message using title and detail when model implements rfc7807

func NewGenericOpenAPIError

func NewGenericOpenAPIError(error string) error

func NewGenericOpenAPIErrorWithBody

func NewGenericOpenAPIErrorWithBody(error string, body []byte) error

func NewGenericOpenAPIErrorWithBodyAndModel

func NewGenericOpenAPIErrorWithBodyAndModel(error string, body []byte, model interface{}) error

func ParameterAddToHeaderOrQuery

func ParameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, collectionType string)

ParameterAddToHeaderOrQuery adds the provided object to the request header or url query supporting deep object syntax

func ParameterValueToString

func ParameterValueToString(obj interface{}, key string) string

func ReportError

func ReportError(format string, a ...interface{}) error

ReportError is to prevent trying to import "fmt"

func SelectHeaderAccept

func SelectHeaderAccept(accepts []string) string

SelectHeaderAccept join all accept types and return

func SelectHeaderContentType

func SelectHeaderContentType(contentTypes []string) string

SelectHeaderContentType select a content type from the available list.

Types

type APIClient

type APIClient struct {
	Cfg    *Configuration
	Common Service // Reuse a single struct instead of allocating one for each service on the heap.
}

APIClient manages communication with the API In most cases there should be only one, shared, APIClient.

func NewAPIClient

func NewAPIClient(basePath string, cfg *Configuration) *APIClient

NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.

func (*APIClient) CallAPI

func (c *APIClient) CallAPI(request *http.Request) (*http.Response, error)

CallAPI do the request.

func (*APIClient) Decode

func (c *APIClient) Decode(v interface{}, b []byte, contentType string) (err error)

func (*APIClient) PrepareRequest

func (c *APIClient) PrepareRequest(
	ctx context.Context,
	path string, method string,
	postBody interface{},
	headerParams map[string]string,
	queryParams url.Values,
	formParams url.Values,
	formFiles []FormFile) (localVarRequest *http.Request, err error)

PrepareRequest build the request

type Configuration

type Configuration struct {
	ClientName       string            `json:"clientName,omitempty"`
	CSPURL           string            `json:"cspURL,omitempty"`
	APIKey           string            `json:"apiKey,omitempty"`
	DefaultHeader    map[string]string `json:"defaultHeader,omitempty"`
	UserAgent        string            `json:"userAgent,omitempty"`
	Debug            bool              `json:"debug,omitempty"`
	Servers          ServerConfigurations
	OperationServers map[string]ServerConfigurations
	HTTPClient       *http.Client
	DefaultTags      map[string]string
}

Configuration stores the configuration of the API client

func NewConfiguration

func NewConfiguration() *Configuration

NewConfiguration returns a new Configuration object. The following default values are set: - ClientName: "bloxone-go-client" - CSPURL: "https://csp.infoblox.com" - UserAgent: "bloxone-go-client/version" - Debug: false

func (*Configuration) AddDefaultHeader

func (c *Configuration) AddDefaultHeader(key string, value string)

AddDefaultHeader adds a new HTTP header to the default header in the request

func (*Configuration) ServerURL

func (c *Configuration) ServerURL(index int, variables map[string]string) (string, error)

ServerURL returns URL based on server settings

func (*Configuration) ServerURLWithContext

func (c *Configuration) ServerURLWithContext(ctx context.Context, endpoint string) (string, error)

ServerURLWithContext returns a new server URL given an endpoint

type FormFile

type FormFile struct {
	FileBytes    []byte
	FileName     string
	FormFileName string
}

type GenericOpenAPIError

type GenericOpenAPIError struct {
	// contains filtered or unexported fields
}

GenericOpenAPIError Provides access to the body, error and model on returned errors.

func (GenericOpenAPIError) Body

func (e GenericOpenAPIError) Body() []byte

Body returns the raw bytes of the response

func (GenericOpenAPIError) Error

func (e GenericOpenAPIError) Error() string

Error returns non-empty string if there was an error.

func (GenericOpenAPIError) Model

func (e GenericOpenAPIError) Model() interface{}

Model returns the unpacked model of the error

type MappedNullable

type MappedNullable interface {
	ToMap() (map[string]interface{}, error)
}

type ServerConfiguration

type ServerConfiguration struct {
	URL         string
	Description string
	Variables   map[string]ServerVariable
}

ServerConfiguration stores the information about a server

type ServerConfigurations

type ServerConfigurations []ServerConfiguration

ServerConfigurations stores multiple ServerConfiguration items

func (ServerConfigurations) URL

func (sc ServerConfigurations) URL(index int, variables map[string]string) (string, error)

URL formats template on a index using given variables

type ServerVariable

type ServerVariable struct {
	Description  string
	DefaultValue string
	EnumValues   []string
}

ServerVariable stores the information about a server variable

type Service

type Service struct {
	Client *APIClient
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL