Documentation ¶
Index ¶
- Constants
- Variables
- func All[T any](xs []T, f func(T) bool) bool
- func Any[T any](xs []T, f func(T) bool) bool
- func ApplyAndAggregateErrors[T any](xs []T, f func(T) error) error
- func ApplyOrFail[T any](xs []T, f func(T) error) error
- func Filter[T any](xs []T, f func(T) bool) []T
- func Fold[T any, Acc any](xs []T, f func(Acc, T) Acc, acc Acc) Acc
- func IsNil(i interface{}) bool
- func Map[T comparable, K any](s []T, f func(T) K) []K
- func MapIdx[V comparable, R any](s []V, f func(int, V) R) []R
- func NewSdkLogger()
- func SetBasePath(basePath string)
- func SliceToValueDefault[T any](ptrSlice *[]T) []T
- func Strlen(s string) int
- func ToPtr[T any](v T) *T
- func ToValue[T any](ptr *T) T
- func ToValueDefault[T any](ptr *T) T
- type APIKey
- type APIResponse
- type BasicAuth
- type Configuration
- func (c *Configuration) AddDefaultHeader(key string, value string)
- func (c *Configuration) AddDefaultQueryParam(key string, value string)
- func (c *Configuration) ServerURL(index int, variables map[string]string) (string, error)
- func (c *Configuration) ServerURLWithContext(ctx context.Context, endpoint string) (string, error)
- type GenericOpenAPIError
- func (e GenericOpenAPIError) Body() []byte
- func (e GenericOpenAPIError) Error() string
- func (e GenericOpenAPIError) Model() interface{}
- func (e *GenericOpenAPIError) SetBody(body []byte)
- func (e *GenericOpenAPIError) SetError(error string)
- func (e *GenericOpenAPIError) SetModel(model interface{})
- func (e *GenericOpenAPIError) SetStatusCode(statusCode int)
- func (e GenericOpenAPIError) StatusCode() int
- type LogLevel
- type Logger
- type Nullable
- type ServerConfiguration
- type ServerConfigurations
- type ServerVariable
Constants ¶
const ( IonosUsernameEnvVar = "IONOS_USERNAME" IonosPasswordEnvVar = "IONOS_PASSWORD" IonosTokenEnvVar = "IONOS_TOKEN" IonosApiUrlEnvVar = "IONOS_API_URL" IonosPinnedCertEnvVar = "IONOS_PINNED_CERT" IonosLogLevelEnvVar = "IONOS_LOG_LEVEL" DefaultIonosServerUrl = "https://api.ionos.com/" )
Variables ¶
var ( // ContextOAuth2 takes an oauth2.TokenSource as authentication for the request. ContextOAuth2 = contextKey("token") // ContextBasicAuth takes BasicAuth as authentication for the request. ContextBasicAuth = contextKey("basic") // ContextAccessToken takes a string oauth2 access token as authentication for the request. ContextAccessToken = contextKey("accesstoken") // ContextAPIKeys takes a string apikey as authentication for the request ContextAPIKeys = contextKey("apiKeys") // ContextHttpSignatureAuth takes HttpSignatureAuth as authentication for the request. ContextHttpSignatureAuth = contextKey("httpsignature") // 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") )
var DefaultIonosBasePath = ""
Functions ¶
func All ¶ added in v0.1.1
All returns true if all elements of a slice satisfy a given predicate function, and false otherwise.
func Any ¶ added in v0.1.1
Any returns true if at least one element of a slice satisfies a given predicate function, and false otherwise.
func ApplyAndAggregateErrors ¶ added in v0.1.1
ApplyAndAggregateErrors applies the provided function for each element of the slice If the function returns an error, it accumulates the error and continues execution After all elements are processed, it returns the aggregated errors if any
func ApplyOrFail ¶ added in v0.1.1
ApplyOrFail tries applying the provided function for each element of the slice If the function returns an error, we break execution and return the error
func Filter ¶ added in v0.1.1
Filter applies a function to each element of a slice, returning a new slice with only the elements for which the function returns true.
func Fold ¶ added in v0.1.1
Fold (aka Reduce) accumulates the result of f into acc and returns acc by applying f over each element in the slice
func Map ¶ added in v0.1.1
func Map[T comparable, K any](s []T, f func(T) K) []K
Map applies a function to each element of a slice and returns the modified slice without considering the index of each element.
func MapIdx ¶ added in v0.1.1
func MapIdx[V comparable, R any](s []V, f func(int, V) R) []R
MapIdx applies a function to each element and index of a slice, returning the modified slice with consideration of the index.
func NewSdkLogger ¶
func NewSdkLogger()
func SetBasePath ¶
func SetBasePath(basePath string)
func SliceToValueDefault ¶
func SliceToValueDefault[T any](ptrSlice *[]T) []T
func ToValue ¶
func ToValue[T any](ptr *T) T
ToValue - returns the value of the bool pointer passed in
func ToValueDefault ¶
func ToValueDefault[T any](ptr *T) T
ToValueDefault - returns the value of the pointer passed in, or the default type value if the pointer is nil
Types ¶
type APIKey ¶
APIKey provides API key based authentication to a request passed via context using ContextAPIKey
type APIResponse ¶
type APIResponse struct { *http.Response `json:"-"` Message string `json:"message,omitempty"` // Operation is the name of the OpenAPI operation. Operation string `json:"operation,omitempty"` // RequestURL is the request URL. This value is always available, even if the // embedded *http.Response is nil. RequestURL string `json:"url,omitempty"` // RequestTime is the time duration from the moment the APIClient sends // the HTTP request to the moment it receives an HTTP response. RequestTime time.Duration `json:"duration,omitempty"` // Method is the HTTP method used for the request. This value is always // available, even if the embedded *http.Response is nil. Method string `json:"method,omitempty"` // Payload holds the contents of the response body (which may be nil or empty). // This is provided here as the raw response.Body() reader will have already // been drained. Payload []byte `json:"-"` }
APIResponse stores the API response returned by the server.
func NewAPIResponse ¶
func NewAPIResponse(r *http.Response) *APIResponse
NewAPIResponse returns a new APIResonse object.
func NewAPIResponseWithError ¶
func NewAPIResponseWithError(errorMessage string) *APIResponse
NewAPIResponseWithError returns a new APIResponse object with the provided error message.
func (*APIResponse) HttpNotFound ¶
func (resp *APIResponse) HttpNotFound() bool
HttpNotFound - returns true if a 404 status code was returned returns false for nil APIResponse values
func (*APIResponse) LogInfo ¶
func (resp *APIResponse) LogInfo()
LogInfo - logs APIResponse values like RequestTime, Operation and StatusCode does not print anything for nil APIResponse values
type BasicAuth ¶
type BasicAuth struct { UserName string `json:"userName,omitempty"` Password string `json:"password,omitempty"` }
BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
type Configuration ¶
type Configuration struct { Host string `json:"host,omitempty"` Scheme string `json:"scheme,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"` DefaultQueryParams url.Values `json:"defaultQueryParams,omitempty"` UserAgent string `json:"userAgent,omitempty"` Servers ServerConfigurations OperationServers map[string]ServerConfigurations HTTPClient *http.Client Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` Token string `json:"token,omitempty"` MaxRetries int `json:"maxRetries,omitempty"` WaitTime time.Duration `json:"waitTime,omitempty"` MaxWaitTime time.Duration `json:"maxWaitTime,omitempty"` }
shared.Configuration stores the configuration of the API client
func NewConfiguration ¶
func NewConfiguration(username, password, token, hostUrl string) *Configuration
NewConfiguration returns a new shared.Configuration object
func NewConfigurationFromEnv ¶
func NewConfigurationFromEnv() *Configuration
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) AddDefaultQueryParam ¶
func (c *Configuration) AddDefaultQueryParam(key string, value string)
func (*Configuration) ServerURLWithContext ¶
ServerURLWithContext returns a new server URL given an endpoint
type GenericOpenAPIError ¶
type GenericOpenAPIError struct {
// contains filtered or unexported fields
}
GenericOpenAPIError Provides access to the body, error and model on returned errors.
func NewGenericOpenAPIError ¶
func NewGenericOpenAPIError(message string, body []byte, model interface{}, statusCode int) *GenericOpenAPIError
NewGenericOpenAPIError - constructor for GenericOpenAPIError
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
func (*GenericOpenAPIError) SetBody ¶
func (e *GenericOpenAPIError) SetBody(body []byte)
SetBody sets the raw body of the error
func (*GenericOpenAPIError) SetError ¶
func (e *GenericOpenAPIError) SetError(error string)
SetError sets the error string
func (*GenericOpenAPIError) SetModel ¶
func (e *GenericOpenAPIError) SetModel(model interface{})
SetModel sets the model of the error
func (*GenericOpenAPIError) SetStatusCode ¶
func (e *GenericOpenAPIError) SetStatusCode(statusCode int)
SetStatusCode sets the status code of the error
func (GenericOpenAPIError) StatusCode ¶
func (e GenericOpenAPIError) StatusCode() int
StatusCode returns the status code of the error
type LogLevel ¶
type LogLevel uint
const ( Off LogLevel = 0x100 * iota Debug // Trace We recommend you only set this field for debugging purposes. // Disable it in your production environments because it can log sensitive data. // It logs the full request and response without encryption, even for an HTTPS call. // Verbose request and response logging can also significantly impact your application's performance. Trace )
var SdkLogLevel LogLevel
type Logger ¶
type Logger interface {
Printf(format string, args ...interface{})
}
var SdkLogger Logger
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
type ServerVariable ¶
ServerVariable stores the information about a server variable