Documentation ¶
Overview ¶
Package core contains functionality used by Go SDK's generated by the IBM OpenAPI 3 SDK Generator (openapi-sdkgen). Authenticators
The go-sdk-core project supports the following types of authentication:
Basic Authentication Bearer Token Identity and Access Management (IAM) Cloud Pak for Data No Authentication
The authentication types that are appropriate for a particular service may vary from service to service. Each authentication type is implemented as an Authenticator for consumption by a service. To read more about authenticators and how to use them see here: https://github.com/IBM/go-sdk-core/blob/main/Authentication.md
Services ¶
Services are the API clients generated by the IBM OpenAPI 3 SDK Generator. These services make use of the code within the core package BaseService instances to perform service operations.
Index ¶
- Constants
- Variables
- func BoolPtr(literal bool) *bool
- func ByteArrayPtr(literal []byte) *[]byte
- func ComputeConsoleMessage(o OrderableProblem) string
- func ComputeDebugMessage(o OrderableProblem) string
- func ConstructServiceURL(parameterizedUrl string, defaultUrlVariables map[string]string, ...) (string, error)
- func ConvertSlice(slice interface{}) (s []string, err error)
- func CreateIDHash(prefix string, fields ...string) string
- func DefaultHTTPClient() *http.Client
- func EnrichHTTPProblem(err error, operationID string, component *ProblemComponent)
- func Float32Ptr(literal float32) *float32
- func Float64Ptr(literal float64) *float64
- func GetCurrentTime() int64
- func GetQueryParam(urlStr *string, param string) (value *string, err error)
- func GetQueryParamAsInt(urlStr *string, param string) (value *int64, err error)
- func GetServiceProperties(serviceName string) (serviceProps map[string]string, err error)
- func HasBadFirstOrLastChar(str string) bool
- func IBMCloudSDKBackoffPolicy(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration
- func IBMCloudSDKRetryPolicy(ctx context.Context, resp *http.Response, err error) (bool, error)
- func Int64Ptr(literal int64) *int64
- func IsJSONMimeType(mimeType string) bool
- func IsJSONPatchMimeType(mimeType string) bool
- func IsNil(object interface{}) bool
- func NewGzipCompressionReader(uncompressedReader io.Reader) (io.Reader, error)
- func NewGzipDecompressionReader(compressedReader io.Reader) (io.Reader, error)
- func NewRetryableClientWithHTTPClient(httpClient *http.Client) *retryablehttp.Client
- func NewRetryableHTTPClient() *retryablehttp.Client
- func NormalizeDateTimeUTC(t time.Time) time.Time
- func ParseDate(dateString string) (fmtDate strfmt.Date, err error)
- func ParseDateTime(dateString string) (strfmt.DateTime, error)
- func PrettyPrint(result interface{}, resultName string)
- func RedactSecrets(input string) string
- func RepurposeSDKProblem(err error, discriminator string) error
- func SetLogger(logger Logger)
- func SetLoggingLevel(level LogLevel)
- func SliceContains(slice []string, contains string) bool
- func StringNilMapper(s *string) string
- func StringPtr(literal string) *string
- func SystemInfo() string
- func UUIDPtr(literal strfmt.UUID) *strfmt.UUID
- func UnmarshalFileWithMetadata(m map[string]json.RawMessage, result interface{}) (err error)
- func UnmarshalModel(rawInput interface{}, propertyName string, result interface{}, ...) (err error)
- func UnmarshalPrimitive(rawInput map[string]json.RawMessage, propertyName string, result interface{}) (err error)
- func UserHomeDir() string
- func ValidateNotNil(object interface{}, errorMsg string) error
- func ValidateStruct(param interface{}, paramName string) error
- type AuthenticationError
- type Authenticator
- type BaseService
- func (service *BaseService) Clone() *BaseService
- func (service *BaseService) ConfigureService(serviceName string) error
- func (service *BaseService) DisableRetries()
- func (service *BaseService) DisableSSLVerification()
- func (service *BaseService) EnableRetries(maxRetries int, maxRetryInterval time.Duration)
- func (service *BaseService) GetEnableGzipCompression() bool
- func (service *BaseService) GetHTTPClient() *http.Client
- func (service *BaseService) GetServiceURL() string
- func (service *BaseService) IsSSLDisabled() bool
- func (service *BaseService) Request(req *http.Request, result interface{}) (detailedResponse *DetailedResponse, err error)
- func (service *BaseService) SetDefaultHeaders(headers http.Header)
- func (service *BaseService) SetEnableGzipCompression(enableGzip bool)
- func (service *BaseService) SetHTTPClient(client *http.Client)
- func (service *BaseService) SetServiceURL(url string) error
- func (service *BaseService) SetURL(url string) errordeprecated
- func (service *BaseService) SetUserAgent(userAgent string)
- type BasicAuthenticator
- type BearerTokenAuthenticator
- type CloudPakForDataAuthenticator
- func NewCloudPakForDataAuthenticator(url string, username string, password string, disableSSLVerification bool, ...) (*CloudPakForDataAuthenticator, error)
- func NewCloudPakForDataAuthenticatorUsingAPIKey(url string, username string, apikey string, disableSSLVerification bool, ...) (*CloudPakForDataAuthenticator, error)
- func NewCloudPakForDataAuthenticatorUsingPassword(url string, username string, password string, disableSSLVerification bool, ...) (*CloudPakForDataAuthenticator, error)
- func (authenticator *CloudPakForDataAuthenticator) Authenticate(request *http.Request) error
- func (*CloudPakForDataAuthenticator) AuthenticationType() string
- func (authenticator *CloudPakForDataAuthenticator) GetToken() (string, error)
- func (authenticator *CloudPakForDataAuthenticator) Validate() error
- type ContainerAuthenticator
- func (authenticator *ContainerAuthenticator) Authenticate(request *http.Request) error
- func (*ContainerAuthenticator) AuthenticationType() string
- func (authenticator *ContainerAuthenticator) GetToken() (string, error)
- func (authenticator *ContainerAuthenticator) RequestToken() (*IamTokenServerResponse, error)
- func (authenticator *ContainerAuthenticator) Validate() error
- type ContainerAuthenticatorBuilder
- func (builder *ContainerAuthenticatorBuilder) Build() (*ContainerAuthenticator, error)
- func (builder *ContainerAuthenticatorBuilder) SetCRTokenFilename(s string) *ContainerAuthenticatorBuilder
- func (builder *ContainerAuthenticatorBuilder) SetClient(client *http.Client) *ContainerAuthenticatorBuilder
- func (builder *ContainerAuthenticatorBuilder) SetClientIDSecret(clientID, clientSecret string) *ContainerAuthenticatorBuilder
- func (builder *ContainerAuthenticatorBuilder) SetDisableSSLVerification(b bool) *ContainerAuthenticatorBuilder
- func (builder *ContainerAuthenticatorBuilder) SetHeaders(headers map[string]string) *ContainerAuthenticatorBuilder
- func (builder *ContainerAuthenticatorBuilder) SetIAMProfileID(s string) *ContainerAuthenticatorBuilder
- func (builder *ContainerAuthenticatorBuilder) SetIAMProfileName(s string) *ContainerAuthenticatorBuilder
- func (builder *ContainerAuthenticatorBuilder) SetScope(s string) *ContainerAuthenticatorBuilder
- func (builder *ContainerAuthenticatorBuilder) SetURL(s string) *ContainerAuthenticatorBuilder
- type DetailedResponse
- func (response *DetailedResponse) GetHeaders() http.Header
- func (response *DetailedResponse) GetRawResult() []byte
- func (response *DetailedResponse) GetResult() interface{}
- func (response *DetailedResponse) GetResultAsMap() (map[string]interface{}, bool)
- func (response *DetailedResponse) GetStatusCode() int
- func (response *DetailedResponse) String() string
- type Error
- type Errors
- type FileWithMetadata
- type FormData
- type HTTPProblem
- type IBMProblem
- type IamAssumeAuthenticator
- func (authenticator *IamAssumeAuthenticator) Authenticate(request *http.Request) error
- func (*IamAssumeAuthenticator) AuthenticationType() string
- func (authenticator *IamAssumeAuthenticator) GetToken() (string, error)
- func (authenticator *IamAssumeAuthenticator) NewBuilder() *IamAssumeAuthenticatorBuilder
- func (authenticator *IamAssumeAuthenticator) RequestToken() (*IamTokenServerResponse, error)
- func (authenticator *IamAssumeAuthenticator) Validate() error
- type IamAssumeAuthenticatorBuilder
- func (builder *IamAssumeAuthenticatorBuilder) Build() (*IamAssumeAuthenticator, error)
- func (builder *IamAssumeAuthenticatorBuilder) SetApiKey(s string) *IamAssumeAuthenticatorBuilder
- func (builder *IamAssumeAuthenticatorBuilder) SetClient(client *http.Client) *IamAssumeAuthenticatorBuilder
- func (builder *IamAssumeAuthenticatorBuilder) SetClientIDSecret(clientID, clientSecret string) *IamAssumeAuthenticatorBuilder
- func (builder *IamAssumeAuthenticatorBuilder) SetDisableSSLVerification(b bool) *IamAssumeAuthenticatorBuilder
- func (builder *IamAssumeAuthenticatorBuilder) SetHeaders(headers map[string]string) *IamAssumeAuthenticatorBuilder
- func (builder *IamAssumeAuthenticatorBuilder) SetIAMAccountID(s string) *IamAssumeAuthenticatorBuilder
- func (builder *IamAssumeAuthenticatorBuilder) SetIAMProfileCRN(s string) *IamAssumeAuthenticatorBuilder
- func (builder *IamAssumeAuthenticatorBuilder) SetIAMProfileID(s string) *IamAssumeAuthenticatorBuilder
- func (builder *IamAssumeAuthenticatorBuilder) SetIAMProfileName(s string) *IamAssumeAuthenticatorBuilder
- func (builder *IamAssumeAuthenticatorBuilder) SetScope(s string) *IamAssumeAuthenticatorBuilder
- func (builder *IamAssumeAuthenticatorBuilder) SetURL(s string) *IamAssumeAuthenticatorBuilder
- type IamAuthenticator
- func (authenticator *IamAuthenticator) Authenticate(request *http.Request) error
- func (*IamAuthenticator) AuthenticationType() string
- func (authenticator *IamAuthenticator) GetToken() (string, error)
- func (authenticator *IamAuthenticator) RequestToken() (*IamTokenServerResponse, error)
- func (authenticator *IamAuthenticator) Validate() error
- type IamAuthenticatorBuilder
- func (builder *IamAuthenticatorBuilder) Build() (*IamAuthenticator, error)
- func (builder *IamAuthenticatorBuilder) SetApiKey(s string) *IamAuthenticatorBuilder
- func (builder *IamAuthenticatorBuilder) SetClient(client *http.Client) *IamAuthenticatorBuilder
- func (builder *IamAuthenticatorBuilder) SetClientIDSecret(clientID, clientSecret string) *IamAuthenticatorBuilder
- func (builder *IamAuthenticatorBuilder) SetDisableSSLVerification(b bool) *IamAuthenticatorBuilder
- func (builder *IamAuthenticatorBuilder) SetHeaders(headers map[string]string) *IamAuthenticatorBuilder
- func (builder *IamAuthenticatorBuilder) SetRefreshToken(s string) *IamAuthenticatorBuilder
- func (builder *IamAuthenticatorBuilder) SetScope(s string) *IamAuthenticatorBuilder
- func (builder *IamAuthenticatorBuilder) SetURL(s string) *IamAuthenticatorBuilder
- type IamTokenServerResponse
- type LogLevel
- type Logger
- type MCSPAuthenticator
- func (authenticator *MCSPAuthenticator) Authenticate(request *http.Request) error
- func (*MCSPAuthenticator) AuthenticationType() string
- func (authenticator *MCSPAuthenticator) GetToken() (string, error)
- func (authenticator *MCSPAuthenticator) RequestToken() (*MCSPTokenServerResponse, error)
- func (authenticator *MCSPAuthenticator) Validate() error
- type MCSPAuthenticatorBuilder
- func (builder *MCSPAuthenticatorBuilder) Build() (*MCSPAuthenticator, error)
- func (builder *MCSPAuthenticatorBuilder) SetApiKey(s string) *MCSPAuthenticatorBuilder
- func (builder *MCSPAuthenticatorBuilder) SetClient(client *http.Client) *MCSPAuthenticatorBuilder
- func (builder *MCSPAuthenticatorBuilder) SetDisableSSLVerification(b bool) *MCSPAuthenticatorBuilder
- func (builder *MCSPAuthenticatorBuilder) SetHeaders(headers map[string]string) *MCSPAuthenticatorBuilder
- func (builder *MCSPAuthenticatorBuilder) SetURL(s string) *MCSPAuthenticatorBuilder
- type MCSPTokenServerResponse
- type ModelUnmarshaller
- type NoAuthAuthenticator
- type OrderableProblem
- type OrderedMaps
- type Problem
- type ProblemComponent
- type RequestBuilder
- func (requestBuilder *RequestBuilder) AddFormData(fieldName string, fileName string, contentType string, contents interface{}) *RequestBuilder
- func (requestBuilder *RequestBuilder) AddHeader(name string, value string) *RequestBuilder
- func (requestBuilder *RequestBuilder) AddQuery(name string, value string) *RequestBuilder
- func (requestBuilder *RequestBuilder) AddQuerySlice(param string, slice interface{}) (err error)
- func (requestBuilder *RequestBuilder) Build() (req *http.Request, err error)
- func (requestBuilder *RequestBuilder) ConstructHTTPURL(serviceURL string, pathSegments []string, pathParameters []string) (*RequestBuilder, error)
- func (requestBuilder *RequestBuilder) ResolveRequestURL(serviceURL string, path string, pathParams map[string]string) (*RequestBuilder, error)
- func (requestBuilder *RequestBuilder) SetBodyContent(contentType string, jsonContent interface{}, jsonPatchContent interface{}, ...) (builder *RequestBuilder, err error)
- func (requestBuilder *RequestBuilder) SetBodyContentForMultipart(contentType string, content interface{}, writer io.Writer) error
- func (requestBuilder *RequestBuilder) SetBodyContentJSON(bodyContent interface{}) (*RequestBuilder, error)
- func (requestBuilder *RequestBuilder) SetBodyContentStream(bodyContent io.Reader) (*RequestBuilder, error)
- func (requestBuilder *RequestBuilder) SetBodyContentString(bodyContent string) (*RequestBuilder, error)
- func (requestBuilder *RequestBuilder) WithContext(ctx context.Context) *RequestBuilder
- type SDKLoggerImpl
- func (l *SDKLoggerImpl) Debug(format string, inserts ...interface{})
- func (l *SDKLoggerImpl) Error(format string, inserts ...interface{})
- func (l *SDKLoggerImpl) GetLogLevel() LogLevel
- func (l *SDKLoggerImpl) Info(format string, inserts ...interface{})
- func (l *SDKLoggerImpl) IsLogLevelEnabled(level LogLevel) bool
- func (l *SDKLoggerImpl) Log(level LogLevel, format string, inserts ...interface{})
- func (l *SDKLoggerImpl) SetLogLevel(level LogLevel)
- func (l *SDKLoggerImpl) Warn(format string, inserts ...interface{})
- type SDKProblem
- type ServiceOptions
- type VpcInstanceAuthenticator
- func (authenticator *VpcInstanceAuthenticator) Authenticate(request *http.Request) error
- func (*VpcInstanceAuthenticator) AuthenticationType() string
- func (authenticator *VpcInstanceAuthenticator) GetToken() (string, error)
- func (authenticator *VpcInstanceAuthenticator) RequestToken() (iamTokenResponse *IamTokenServerResponse, err error)
- func (authenticator *VpcInstanceAuthenticator) Validate() error
- type VpcInstanceAuthenticatorBuilder
- func (builder *VpcInstanceAuthenticatorBuilder) Build() (*VpcInstanceAuthenticator, error)
- func (builder *VpcInstanceAuthenticatorBuilder) SetClient(client *http.Client) *VpcInstanceAuthenticatorBuilder
- func (builder *VpcInstanceAuthenticatorBuilder) SetIAMProfileCRN(s string) *VpcInstanceAuthenticatorBuilder
- func (builder *VpcInstanceAuthenticatorBuilder) SetIAMProfileID(s string) *VpcInstanceAuthenticatorBuilder
- func (builder *VpcInstanceAuthenticatorBuilder) SetURL(s string) *VpcInstanceAuthenticatorBuilder
Constants ¶
const ( // IBM_CREDENTIAL_FILE_ENVVAR is the environment key used to find the path to // a credentials file. IBM_CREDENTIAL_FILE_ENVVAR = "IBM_CREDENTIALS_FILE" // DEFAULT_CREDENTIAL_FILE_NAME is the default filename for a credentials file. // It is used when "IBM_CREDENTIALS_FILE" is not specified. The filename will // be searched for within the program's working directory, and then the OS's // current user directory. DEFAULT_CREDENTIAL_FILE_NAME = "ibm-credentials.env" )
const ( // Supported authentication types. AUTHTYPE_BASIC = "basic" AUTHTYPE_BEARER_TOKEN = "bearerToken" AUTHTYPE_NOAUTH = "noAuth" AUTHTYPE_IAM = "iam" AUTHTYPE_IAM_ASSUME = "iamAssume" AUTHTYPE_CP4D = "cp4d" AUTHTYPE_CONTAINER = "container" AUTHTYPE_VPC = "vpc" AUTHTYPE_MCSP = "mcsp" // Service client properties. PROPNAME_SVC_URL = "URL" PROPNAME_SVC_DISABLE_SSL = "DISABLE_SSL" PROPNAME_SVC_ENABLE_GZIP = "ENABLE_GZIP" PROPNAME_SVC_ENABLE_RETRIES = "ENABLE_RETRIES" PROPNAME_SVC_MAX_RETRIES = "MAX_RETRIES" PROPNAME_SVC_RETRY_INTERVAL = "RETRY_INTERVAL" // Authenticator properties. PROPNAME_AUTH_TYPE = "AUTH_TYPE" PROPNAME_USERNAME = "USERNAME" PROPNAME_PASSWORD = "PASSWORD" PROPNAME_BEARER_TOKEN = "BEARER_TOKEN" PROPNAME_AUTH_URL = "AUTH_URL" PROPNAME_AUTH_DISABLE_SSL = "AUTH_DISABLE_SSL" PROPNAME_APIKEY = "APIKEY" PROPNAME_REFRESH_TOKEN = "REFRESH_TOKEN" // #nosec G101 PROPNAME_CLIENT_ID = "CLIENT_ID" PROPNAME_CLIENT_SECRET = "CLIENT_SECRET" PROPNAME_SCOPE = "SCOPE" PROPNAME_CRTOKEN_FILENAME = "CR_TOKEN_FILENAME" // #nosec G101 PROPNAME_IAM_PROFILE_CRN = "IAM_PROFILE_CRN" PROPNAME_IAM_PROFILE_NAME = "IAM_PROFILE_NAME" PROPNAME_IAM_PROFILE_ID = "IAM_PROFILE_ID" PROPNAME_IAM_ACCOUNT_ID = "IAM_ACCOUNT_ID" // SSL error SSL_CERTIFICATION_ERROR = "x509: certificate" // Common error messages. ERRORMSG_PROP_MISSING = "The %s property is required but was not specified." ERRORMSG_PROP_INVALID = "The %s property is invalid. Please remove any surrounding {, }, or \" characters." ERRORMSG_EXCLUSIVE_PROPS_ERROR = "Exactly one of %s or %s must be specified." ERRORMSG_ATLEAST_ONE_PROP_ERROR = "At least one of %s or %s must be specified." ERRORMSG_ATMOST_ONE_PROP_ERROR = "At most one of %s or %s may be specified." ERRORMSG_NO_AUTHENTICATOR = "Authentication information was not properly configured." ERRORMSG_AUTHTYPE_UNKNOWN = "Unrecognized authentication type: %s" ERRORMSG_PROPS_MAP_NIL = "The 'properties' map cannot be nil." ERRORMSG_SSL_VERIFICATION_FAILED = "The connection failed because the SSL certificate is not valid. To use a " + "self-signed certificate, disable verification of the server's SSL certificate " + "by invoking the DisableSSLVerification() function on your service instance " + "and/or use the DisableSSLVerification option of the authenticator." ERRORMSG_AUTHENTICATE_ERROR = "An error occurred while performing the 'authenticate' step: %s" ERRORMSG_READ_RESPONSE_BODY = "An error occurred while reading the response body: %s" ERRORMSG_UNEXPECTED_RESPONSE = "The response contained unexpected content, Content-Type=%s, operation resultType=%s" ERRORMSG_UNMARSHAL_RESPONSE_BODY = "An error occurred while processing the HTTP response: %s" ERRORMSG_NIL_SLICE = "The 'slice' parameter cannot be nil" ERRORMSG_PARAM_NOT_SLICE = "The 'slice' parameter must be a slice" ERRORMSG_MARSHAL_SLICE = "An error occurred while marshalling the slice: %s" ERRORMSG_CONVERT_SLICE = "An error occurred while converting 'slice' to string slice" ERRORMSG_UNEXPECTED_STATUS_CODE = "Unexpected HTTP status code %d (%s)" ERRORMSG_UNMARSHAL_AUTH_RESPONSE = "error unmarshalling authentication response: %s" ERRORMSG_UNABLE_RETRIEVE_CRTOKEN = "unable to retrieve compute resource token value: %s" // #nosec G101 ERRORMSG_IAM_GETTOKEN_ERROR = "IAM 'get token' error, status code %d received from '%s': %s" // #nosec G101 ERRORMSG_UNABLE_RETRIEVE_IITOKEN = "unable to retrieve instance identity token value: %s" // #nosec G101 ERRORMSG_VPCMDS_OPERATION_ERROR = "VPC metadata service error, status code %d received from '%s': %s" ERRORMSG_ACCOUNTID_PROP_ERROR = "IAMAccountID must be specified if and only if IAMProfileName is specified" // The name of this module - matches the value in the go.mod file. MODULE_NAME = "github.com/IBM/go-sdk-core/v5" )
const ( ErrorSeverity problemSeverity = "error" WarningSeverity problemSeverity = "warning" )
const ( POST = http.MethodPost GET = http.MethodGet DELETE = http.MethodDelete PUT = http.MethodPut PATCH = http.MethodPatch HEAD = http.MethodHead )
common HTTP methods
const ( Accept = "Accept" APPLICATION_JSON = "application/json" CONTENT_DISPOSITION = "Content-Disposition" CONTENT_ENCODING = "Content-Encoding" CONTENT_TYPE = "Content-Type" FORM_URL_ENCODED_HEADER = "application/x-www-form-urlencoded" ERRORMSG_SERVICE_URL_MISSING = "service URL is empty" ERRORMSG_SERVICE_URL_INVALID = "error parsing service URL: %s" ERRORMSG_PATH_PARAM_EMPTY = "path parameter '%s' is empty" )
common headers
Variables ¶
var Validate *validator.Validate
Validate is a shared validator instance used to perform validation of structs.
Functions ¶
func ByteArrayPtr ¶ added in v5.12.0
ByteArrayPtr returns a pointer to []byte literal.
func ComputeConsoleMessage ¶ added in v5.16.0
func ComputeConsoleMessage(o OrderableProblem) string
func ComputeDebugMessage ¶ added in v5.16.0
func ComputeDebugMessage(o OrderableProblem) string
func ConstructServiceURL ¶ added in v5.5.0
func ConstructServiceURL( parameterizedUrl string, defaultUrlVariables map[string]string, providedUrlVariables map[string]string, ) (string, error)
ConstructServiceURL returns a service URL that is constructed by formatting a parameterized URL.
Parameters:
parameterizedUrl: URL that contains variable placeholders, e.g. "{scheme}://ibm.com".
defaultUrlVariables: map from variable names to default values.
Each variable in the parameterized URL must have a default value specified in this map.
providedUrlVariables: map from variable names to desired values.
If a variable is not provided in this map, the default variable value will be used instead.
func ConvertSlice ¶
ConvertSlice marshals 'slice' to a json string, performs string manipulation on the resulting string, and converts the string to a '[]string'. If 'slice' is nil, not a 'slice' type, or an error occurred during conversion, an error will be returned
func CreateIDHash ¶ added in v5.16.0
CreateIDHash computes a unique ID based on a given prefix and problem attribute fields.
func DefaultHTTPClient ¶
DefaultHTTPClient returns a non-retryable http client with default configuration.
func EnrichHTTPProblem ¶ added in v5.16.0
func EnrichHTTPProblem(err error, operationID string, component *ProblemComponent)
EnrichHTTPProblem takes an problem and, if it originated as an HTTPProblem, populates the fields of the underlying HTTP problem with the given service/operation information.
func Float32Ptr ¶
Float32Ptr returns a pointer to float32 literal.
func Float64Ptr ¶
Float64Ptr returns a pointer to float64 literal.
func GetQueryParam ¶ added in v5.2.0
GetQueryParam returns a pointer to the value of query parameter `param` from urlStr, or nil if not found.
func GetQueryParamAsInt ¶ added in v5.10.0
GetQueryParamAsInt returns a pointer to the value of query parameter `param` from urlStr converted to an int64 value, or nil if not found.
func GetServiceProperties ¶
GetServiceProperties returns a map containing configuration properties for the specified service that are retrieved from external configuration sources in the following precedence order: 1) credential file 2) environment variables 3) VCAP_SERVICES
'serviceName' is used as a filter against the property names. For example, if serviceName is passed in as "my_service", then configuration properties whose names begin with "MY_SERVICE_" will be returned in the map.
func HasBadFirstOrLastChar ¶
HasBadFirstOrLastChar checks if the string starts with `{` or `"` or ends with `}` or `"`.
func IBMCloudSDKBackoffPolicy ¶
func IBMCloudSDKBackoffPolicy(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration
IBMCloudSDKBackoffPolicy provides a default implementation of the Backoff interface associated with a retryablehttp.Client. This function will return the wait time to be associated with the next retry attempt.
func IBMCloudSDKRetryPolicy ¶
IBMCloudSDKRetryPolicy provides a default implementation of the CheckRetry interface associated with a retryablehttp.Client. This function will return true if the specified request/response should be retried.
func IsJSONMimeType ¶
IsJSONMimeType Returns true iff the specified mimeType value represents a "JSON" mimetype.
func IsJSONPatchMimeType ¶
IsJSONPatchMimeType returns true iff the specified mimeType value represents a "JSON Patch" mimetype.
func IsNil ¶
func IsNil(object interface{}) bool
IsNil checks if the specified object is nil or not.
func NewGzipCompressionReader ¶
NewGzipCompressionReader will return an io.Reader instance that will deliver the gzip-compressed version of the "uncompressedReader" argument. This function was inspired by this github gist:
https://gist.github.com/tomcatzh/cf8040820962e0f8c04700eb3b2f26be
func NewGzipDecompressionReader ¶
NewGzipDecompressionReader will return an io.Reader instance that will deliver the gzip-decompressed version of the "compressedReader" argument.
func NewRetryableClientWithHTTPClient ¶ added in v5.9.4
func NewRetryableClientWithHTTPClient(httpClient *http.Client) *retryablehttp.Client
NewRetryableClientWithHTTPClient will return a new instance of a retryable client, using "httpClient" as the embedded client used to invoke individual requests within the retry logic. If "httpClient" is passed in as nil, then a default HTTP client will be used as the embedded client instead.
func NewRetryableHTTPClient ¶
func NewRetryableHTTPClient() *retryablehttp.Client
NewRetryableHTTPClient returns a new instance of a retryable client with a default configuration that supports Go SDK usage.
func NormalizeDateTimeUTC ¶
NormalizeDateTimeUTC normalizes t to reflect UTC timezone for marshaling
func ParseDate ¶ added in v5.1.0
ParseDate parses the specified RFC3339 full-date string (YYYY-MM-DD) and returns a strfmt.Date instance. If the string is empty the return value will be the unix epoch (1970-01-01).
func ParseDateTime ¶ added in v5.1.0
ParseDateTime parses the specified date-time string and returns a strfmt.DateTime instance. If the string is empty the return value will be the unix epoch (1970-01-01T00:00:00.000Z).
func PrettyPrint ¶
func PrettyPrint(result interface{}, resultName string)
PrettyPrint print pretty.
func RedactSecrets ¶ added in v5.7.1
RedactSecrets() returns the input string with secrets redacted.
func RepurposeSDKProblem ¶ added in v5.16.0
RepurposeSDKProblem provides a convenient way to take a problem from another function in the same component and contextualize it to the current function. Should only be used in public (exported) functions.
func SetLogger ¶
func SetLogger(logger Logger)
SetLogger sets the specified Logger instance as the logger to be used by the Go core library.
func SetLoggingLevel ¶
func SetLoggingLevel(level LogLevel)
SetLoggingLevel will enable the specified logging level in the Go core library.
func SliceContains ¶
SliceContains returns true iff "contains" is an element of "slice"
func StringNilMapper ¶
StringNilMapper de-references the parameter 's' and returns the result, or "" if 's' is nil.
func UnmarshalFileWithMetadata ¶ added in v5.4.0
func UnmarshalFileWithMetadata(m map[string]json.RawMessage, result interface{}) (err error)
UnmarshalFileWithMetadata unmarshals an instance of FileWithMetadata from the specified map of raw messages. The "data" field is assumed to be a string, the value of which is assumed to be a path to the file that contains the data intended for the FileWithMetadata struct.
func UnmarshalModel ¶
func UnmarshalModel(rawInput interface{}, propertyName string, result interface{}, unmarshaller ModelUnmarshaller) (err error)
UnmarshalModel unmarshals 'rawInput' into 'result' while using 'unmarshaller' to unmarshal model instances. This function is the single public interface to the various flavors of model-related unmarshal functions. The values passed in for the 'rawInput', 'propertyName' and 'result' fields will determine the function performed.
Parameters: rawInput: the unmarshal input source. The various types associated with this parameter are described below in "Usage Notes".
propertyName: an optional property name. If specified as "", then 'rawInput' is assumed to directly contain the input source to be used for the unmarshal operation. If propertyName is specified as a non-empty string, then 'rawInput' is assumed to be a map[string]json.RawMessage, and rawInput[propertyName] contains the input source to be unmarshalled.
result: the unmarshal destination. This should be passed in as one of the following types of values:
- **<model> (a ptr to a ptr to a <model> instance)
- *[]<model> (a ptr to a <model> slice)
- *[][]<model> (a ptr to a slice of <model> slices)
- *map[string]<model> (a ptr to a map of <model> instances)
- *map[string][]<model> (a ptr to a map of <model> slices)
unmarshaller: the unmarshaller function to be used to unmarshal each model instance
Usage Notes: if 'result' is a: | and propertyName is: | then 'rawInput' should be: -------------------+--------------------------+------------------------------------------------------------------ **Foo | == "" | a map[string]json.RawMessage which directly
| | contains an instance of model Foo (i.e. each map entry represents | | a property of Foo) | |
**Foo | != "" (e.g. "prop") | a map[string]json.RawMessage and rawInput["prop"]
| | should contain an instance of Foo (i.e. it can itself be | | unmarshalled into a map[string]json.RawMessage whose entries | | represent the properties of Foo)
-------------------+--------------------------+------------------------------------------------------------------ *[]Foo | == "" | a []json.RawMessage where each slice element contains
| | an instance of Foo (i.e. the json.RawMessage can be unmarshalled | | into a Foo instance) | |
*[]Foo | != "" (e.g. "prop") | a map[string]json.RawMessage and rawInput["prop"]
| | contains a []Foo (slice of Foo instances)
-------------------+--------------------------+------------------------------------------------------------------ *[][]Foo | == "" | a []json.RawMessage where each slice element contains
| | a []Foo (i.e. the json.RawMessage can be unmarshalled | | into a []Foo) | |
*[][]Foo | != "" (e.g. "prop") | a map[string]json.RawMessage and rawInput["prop"]
| | contains a [][]Foo (slice of Foo slices)
-------------------+--------------------------+------------------------------------------------------------------ *map[string]Foo | == "" | a map[string]json.RawMessage which directly contains the
| | map[string]Foo (i.e. the value within each entry in 'rawInput' | | contains an instance of Foo) | |
*map[string]Foo | != "" (e.g. "prop") | a map[string]json.RawMessage and rawInput["prop"]
| | contains an instance of map[string]Foo
-------------------+--------------------------+------------------------------------------------------------------ *map[string][]Foo | == "" | a map[string]json.RawMessage which directly contains the
| | map[string][]Foo (i.e. the value within each entry in 'rawInput' | | contains a []Foo)
*map[string][]Foo | != "" (e.g. "prop") | a map[string]json.RawMessage and rawInput["prop"]
| | contains an instance of map[string][]Foo
-------------------+--------------------------+------------------------------------------------------------------
func UnmarshalPrimitive ¶
func UnmarshalPrimitive(rawInput map[string]json.RawMessage, propertyName string, result interface{}) (err error)
UnmarshalPrimitive retrieves the specified property from 'rawInput', then unmarshals the resulting value into 'result'.
This function will typically be invoked from within a model's generated "Unmarshal<model>()" method to unmarshal a struct field (model property) involving a primitive type (a scalar value, a slice, a map of the primitive, etc.). In this context, "primitive" refers to a type other than a user-defined model type within an OpenAPI definition. The 'rawInput' parameter is expected to be a map that contains an instance of a user-defined model type.
Parameters:
rawInput: the unmarshal input source in the form of a map[string]json.RawMessage The value 'rawInput[propertyName]' must be a json.RawMessage that contains an instance of the type inferred from the value passed in as 'result'.
propertyName: the name of the property (map entry) to retrieve from 'rawInput'. This entry's value will be used as the unmarshal input source.
result: a pointer to the unmarshal destination. This could be any of the following:
- *<primitive-type>
- **<primitive-type>
- *[]<primitive-type>
- *[][]<primitive-type>
- *map[string]<primitive-type>
- *map[string][]<primitive-type>
- *[]map[string]<primitive-type>
- *[]map[string][]<primitive-type>
Where <primitive-type> could be any of the following:
- string, bool, []byte, int64, float32, float64, strfmt.Date, strfmt.DateTime, strfmt.UUID, interface{} (any), or map[string]interface{} (any object).
Example:
type MyStruct struct { Field1 *string, Field2 map[string]int64 }
myStruct := new(MyStruct) jsonString := `{ "field1": "value1", "field2": {"foo": 44, "bar": 74}}` var rawMessageMap map[string]json.RawMessage var err error err = UnmarshalPrimitive(rawMessageMap, "field1", &myStruct.Field1) err = UnmarshalPrimitive(rawMessageMap, "field2", &myString.Field2)
func ValidateNotNil ¶
ValidateNotNil returns the specified error if 'object' is nil, nil otherwise.
func ValidateStruct ¶
ValidateStruct validates 'param' (assumed to be a ptr to a struct) according to the annotations attached to its fields.
Types ¶
type AuthenticationError ¶
type AuthenticationError struct { Err error *HTTPProblem }
AuthenticationError describes the problem returned when authentication over HTTP fails.
func NewAuthenticationError ¶
func NewAuthenticationError(response *DetailedResponse, err error) *AuthenticationError
NewAuthenticationError is a deprecated function that was previously used for creating new AuthenticationError structs. HTTPProblem types should be used instead of AuthenticationError types.
type Authenticator ¶
type Authenticator interface { AuthenticationType() string Authenticate(*http.Request) error Validate() error }
Authenticator describes the set of methods implemented by each authenticator.
func GetAuthenticatorFromEnvironment ¶
func GetAuthenticatorFromEnvironment(credentialKey string) (authenticator Authenticator, err error)
GetAuthenticatorFromEnvironment instantiates an Authenticator using service properties retrieved from external config sources.
type BaseService ¶
type BaseService struct { // Configuration values for a service. Options *ServiceOptions // A set of "default" http headers to be included with each outbound request. DefaultHeaders http.Header // The HTTP Client used to send requests and receive responses. Client *http.Client // The value to be used for the "User-Agent" HTTP header that is added to each // outbound request. If this value is not set, then a default value will be // used for the header. UserAgent string }
BaseService implements the common functionality shared by generated services to manage requests and responses, authenticate outbound requests, etc.
func NewBaseService ¶
func NewBaseService(options *ServiceOptions) (*BaseService, error)
NewBaseService constructs a new instance of BaseService. Validation on input parameters and service options will be performed before instance creation.
func (*BaseService) Clone ¶
func (service *BaseService) Clone() *BaseService
Clone will return a copy of "service" suitable for use by a generated service instance to process requests.
func (*BaseService) ConfigureService ¶
func (service *BaseService) ConfigureService(serviceName string) error
ConfigureService updates the service with external configuration values.
func (*BaseService) DisableRetries ¶
func (service *BaseService) DisableRetries()
DisableRetries will disable automatic retries in the service.
func (*BaseService) DisableSSLVerification ¶
func (service *BaseService) DisableSSLVerification()
DisableSSLVerification will configure the service to skip the verification of server certificates and hostnames. This will make the client susceptible to "man-in-the-middle" attacks. This should be used only for testing or in secure environments.
func (*BaseService) EnableRetries ¶
func (service *BaseService) EnableRetries(maxRetries int, maxRetryInterval time.Duration)
EnableRetries will configure the service to perform automatic retries of failed requests. If "maxRetries" and/or "maxRetryInterval" are specified as 0, then default values are used instead.
In a scenario where retries ARE NOT enabled: - BaseService.Client will be a "normal" http.Client instance used to invoke requests - BaseService.Client.Transport will be an instance of the default http.RoundTripper - BaseService.Client.Do() calls http.RoundTripper.RoundTrip() to invoke the request - Only one http.Client instance needed/used (BaseService.Client) in this scenario - Result: "normal" request processing without any automatic retries being performed
In a scenario where retries ARE enabled:
- BaseService.Client will be a "shim" http.Client instance
- BaseService.Client.Transport will be an instance of retryablehttp.RoundTripper
- BaseService.Client.Do() calls retryablehttp.RoundTripper.RoundTrip() (via the shim) to invoke the request
- The retryablehttp.RoundTripper instance is configured with the retryablehttp.Client instance which holds the various retry config properties (max retries, max interval, etc.)
- The retryablehttp.RoundTripper.RoundTrip() method triggers the retry logic in the retryablehttp.Client
- The retryablehttp.Client instance's HTTPClient field holds a "normal" http.Client instance, which is used to invoke individual requests within the retry loop.
- To summarize, there are three client instances used for request processing in this scenario: 1. The "shim" http.Client instance (BaseService.Client) 2. The retryablehttp.Client instance that implements the retry logic 3. The "normal" http.Client instance embedded in the retryablehttp.Client which is used to invoke individual requests within the retry logic
- Result: Each request is invoked such that the automatic retry logic is employed
func (*BaseService) GetEnableGzipCompression ¶
func (service *BaseService) GetEnableGzipCompression() bool
GetEnableGzipCompression returns the service's EnableGzipCompression field
func (*BaseService) GetHTTPClient ¶ added in v5.9.4
func (service *BaseService) GetHTTPClient() *http.Client
GetHTTPClient will return the http.Client instance used to invoke individual HTTP requests. If automatic retries are enabled, the returned value will be the http.Client instance embedded within the retryable client. If automatic retries are not enabled, then the returned value will simply be the "Client" field of the base service.
func (*BaseService) GetServiceURL ¶
func (service *BaseService) GetServiceURL() string
GetServiceURL returns the service URL.
func (*BaseService) IsSSLDisabled ¶
func (service *BaseService) IsSSLDisabled() bool
IsSSLDisabled returns true if and only if the service's http.Client instance is configured to skip verification of server SSL certificates.
func (*BaseService) Request ¶
func (service *BaseService) Request(req *http.Request, result interface{}) (detailedResponse *DetailedResponse, err error)
Request invokes the specified HTTP request and returns the response.
Parameters: req: the http.Request object that holds the request information
result: a pointer to the operation result. This should be one of:
- *io.ReadCloser (for a byte-stream type response)
- *<primitive>, *[]<primitive>, *map[string]<primitive>
- *map[string]json.RawMessage, *[]json.RawMessage
Return values: detailedResponse: a DetailedResponse instance containing the status code, headers, etc.
err: a non-nil error object if an error occurred
func (*BaseService) SetDefaultHeaders ¶
func (service *BaseService) SetDefaultHeaders(headers http.Header)
SetDefaultHeaders sets HTTP headers to be sent in every request.
func (*BaseService) SetEnableGzipCompression ¶
func (service *BaseService) SetEnableGzipCompression(enableGzip bool)
SetEnableGzipCompression sets the service's EnableGzipCompression field
func (*BaseService) SetHTTPClient ¶
func (service *BaseService) SetHTTPClient(client *http.Client)
SetHTTPClient will set "client" as the http.Client instance to be used to invoke individual HTTP requests. If automatic retries are currently enabled on "service", then "client" will be set as the embedded client instance within the retryable client; otherwise "client" will be stored directly on "service".
func (*BaseService) SetServiceURL ¶
func (service *BaseService) SetServiceURL(url string) error
SetServiceURL sets the service URL.
func (*BaseService) SetURL
deprecated
func (service *BaseService) SetURL(url string) error
SetURL sets the service URL.
Deprecated: use SetServiceURL instead.
func (*BaseService) SetUserAgent ¶
func (service *BaseService) SetUserAgent(userAgent string)
SetUserAgent sets the user agent value.
type BasicAuthenticator ¶
type BasicAuthenticator struct { // Username is the user-supplied basic auth username [required]. Username string // Password is the user-supplied basic auth password [required]. Password string }
BasicAuthenticator takes a user-supplied username and password, and adds them to requests via an Authorization header of the form:
Authorization: Basic <encoded username and password>
func NewBasicAuthenticator ¶
func NewBasicAuthenticator(username string, password string) (*BasicAuthenticator, error)
NewBasicAuthenticator constructs a new BasicAuthenticator instance.
func (*BasicAuthenticator) Authenticate ¶
func (authenticator *BasicAuthenticator) Authenticate(request *http.Request) error
Authenticate adds basic authentication information to a request.
Basic Authorization will be added to the request's headers in the form:
Authorization: Basic <encoded username and password>
func (BasicAuthenticator) AuthenticationType ¶
func (BasicAuthenticator) AuthenticationType() string
AuthenticationType returns the authentication type for this authenticator.
func (BasicAuthenticator) Validate ¶
func (authenticator BasicAuthenticator) Validate() error
Validate the authenticator's configuration.
Ensures the username and password are not Nil. Additionally, ensures they do not contain invalid characters.
type BearerTokenAuthenticator ¶
type BearerTokenAuthenticator struct { // The bearer token value to be used to authenticate request [required]. BearerToken string }
BearerTokenAuthenticator will take a user-supplied bearer token and adds it to requests via an Authorization header of the form:
Authorization: Bearer <bearer-token>
func NewBearerTokenAuthenticator ¶
func NewBearerTokenAuthenticator(bearerToken string) (*BearerTokenAuthenticator, error)
NewBearerTokenAuthenticator constructs a new BearerTokenAuthenticator instance.
func (*BearerTokenAuthenticator) Authenticate ¶
func (authenticator *BearerTokenAuthenticator) Authenticate(request *http.Request) error
Authenticate adds bearer authentication information to the request.
The bearer token will be added to the request's headers in the form:
Authorization: Bearer <bearer-token>
func (BearerTokenAuthenticator) AuthenticationType ¶
func (BearerTokenAuthenticator) AuthenticationType() string
AuthenticationType returns the authentication type for this authenticator.
func (BearerTokenAuthenticator) Validate ¶
func (authenticator BearerTokenAuthenticator) Validate() error
Validate the authenticator's configuration.
Ensures the bearer token is not Nil.
type CloudPakForDataAuthenticator ¶
type CloudPakForDataAuthenticator struct { // The URL representing the Cloud Pak for Data token service endpoint [required]. URL string // The username used to obtain a bearer token [required]. Username string // The password used to obtain a bearer token [required if APIKey not specified]. // One of Password or APIKey must be specified. Password string // The apikey used to obtain a bearer token [required if Password not specified]. // One of Password or APIKey must be specified. APIKey string // A flag that indicates whether verification of the server's SSL certificate // should be disabled; defaults to false [optional]. DisableSSLVerification bool // Default headers to be sent with every CP4D token request [optional]. Headers map[string]string // The http.Client object used to invoke token server requests [optional]. If // not specified, a suitable default Client will be constructed. Client *http.Client // contains filtered or unexported fields }
CloudPakForDataAuthenticator uses either a username/password pair or a username/apikey pair to obtain a suitable bearer token from the CP4D authentication service, and adds the bearer token to requests via an Authorization header of the form:
Authorization: Bearer <bearer-token>
func NewCloudPakForDataAuthenticator ¶
func NewCloudPakForDataAuthenticator(url string, username string, password string, disableSSLVerification bool, headers map[string]string) (*CloudPakForDataAuthenticator, error)
NewCloudPakForDataAuthenticator constructs a new CloudPakForDataAuthenticator instance from a username/password pair. This is the default way to create an authenticator and is a wrapper around the NewCloudPakForDataAuthenticatorUsingPassword() function
func NewCloudPakForDataAuthenticatorUsingAPIKey ¶
func NewCloudPakForDataAuthenticatorUsingAPIKey(url string, username string, apikey string, disableSSLVerification bool, headers map[string]string) (*CloudPakForDataAuthenticator, error)
NewCloudPakForDataAuthenticatorUsingAPIKey constructs a new CloudPakForDataAuthenticator instance from a username/apikey pair.
func NewCloudPakForDataAuthenticatorUsingPassword ¶
func NewCloudPakForDataAuthenticatorUsingPassword(url string, username string, password string, disableSSLVerification bool, headers map[string]string) (*CloudPakForDataAuthenticator, error)
NewCloudPakForDataAuthenticatorUsingPassword constructs a new CloudPakForDataAuthenticator instance from a username/password pair.
func (*CloudPakForDataAuthenticator) Authenticate ¶
func (authenticator *CloudPakForDataAuthenticator) Authenticate(request *http.Request) error
Authenticate adds the bearer token (obtained from the token server) to the specified request.
The CP4D bearer token will be added to the request's headers in the form:
Authorization: Bearer <bearer-token>
func (*CloudPakForDataAuthenticator) AuthenticationType ¶
func (*CloudPakForDataAuthenticator) AuthenticationType() string
AuthenticationType returns the authentication type for this authenticator.
func (*CloudPakForDataAuthenticator) GetToken ¶ added in v5.5.1
func (authenticator *CloudPakForDataAuthenticator) GetToken() (string, error)
GetToken: returns an access token to be used in an Authorization header. Whenever a new token is needed (when a token doesn't yet exist, needs to be refreshed, or the existing token has expired), a new access token is fetched from the token server.
func (*CloudPakForDataAuthenticator) Validate ¶
func (authenticator *CloudPakForDataAuthenticator) Validate() error
Validate the authenticator's configuration.
Ensures the username, password, and url are not Nil. Additionally, ensures they do not contain invalid characters.
type ContainerAuthenticator ¶ added in v5.6.3
type ContainerAuthenticator struct { // [optional] The name of the file containing the injected CR token value (applies to // IKS-managed compute resources). // Default value: (1) "/var/run/secrets/tokens/vault-token" or (2) "/var/run/secrets/tokens/sa-token", // whichever is found first. CRTokenFilename string // [optional] The name of the linked trusted IAM profile to be used when obtaining the IAM access token. // One of IAMProfileName or IAMProfileID must be specified. // Default value: "" IAMProfileName string // [optional] The id of the linked trusted IAM profile to be used when obtaining the IAM access token. // One of IAMProfileName or IAMProfileID must be specified. // Default value: "" IAMProfileID string // [optional] The IAM token server's base endpoint URL. // Default value: "https://iam.cloud.ibm.com" URL string // [optional] The ClientID and ClientSecret fields are used to form a "basic auth" // Authorization header for interactions with the IAM token server. // If neither field is specified, then no Authorization header will be sent // with token server requests. // These fields are both optional, but must be specified together. // Default value: "" ClientID string ClientSecret string // [optional] A flag that indicates whether verification of the server's SSL certificate // should be disabled. // Default value: false DisableSSLVerification bool // [optional] The "scope" to use when fetching the access token from the IAM token server. // This can be used to obtain an access token with a specific scope. // Default value: "" Scope string // [optional] A set of key/value pairs that will be sent as HTTP headers in requests // made to the IAM token server. // Default value: nil Headers map[string]string // [optional] The http.Client object used in interacts with the IAM token server. // If not specified by the user, a suitable default Client will be constructed. Client *http.Client // contains filtered or unexported fields }
ContainerAuthenticator implements an IAM-based authentication schema whereby it retrieves a "compute resource token" from the local compute resource (VM) and uses that to obtain an IAM access token by invoking the IAM "get token" operation with grant-type=cr-token. The resulting IAM access token is then added to outbound requests in an Authorization header of the form:
Authorization: Bearer <access-token>
func (*ContainerAuthenticator) Authenticate ¶ added in v5.6.3
func (authenticator *ContainerAuthenticator) Authenticate(request *http.Request) error
Authenticate adds IAM authentication information to the request.
The IAM access token will be added to the request's headers in the form:
Authorization: Bearer <access-token>
func (*ContainerAuthenticator) AuthenticationType ¶ added in v5.6.3
func (*ContainerAuthenticator) AuthenticationType() string
AuthenticationType returns the authentication type for this authenticator.
func (*ContainerAuthenticator) GetToken ¶ added in v5.6.3
func (authenticator *ContainerAuthenticator) GetToken() (string, error)
GetToken returns an access token to be used in an Authorization header. Whenever a new token is needed (when a token doesn't yet exist or the existing token has expired), a new access token is fetched from the token server.
func (*ContainerAuthenticator) RequestToken ¶ added in v5.6.3
func (authenticator *ContainerAuthenticator) RequestToken() (*IamTokenServerResponse, error)
RequestToken first retrieves a CR token value from the current compute resource, then uses that to obtain a new IAM access token from the IAM token server.
func (*ContainerAuthenticator) Validate ¶ added in v5.6.3
func (authenticator *ContainerAuthenticator) Validate() error
Validate the authenticator's configuration.
Ensures that one of IAMProfileName or IAMProfileID are specified, and the ClientId and ClientSecret pair are mutually inclusive.
type ContainerAuthenticatorBuilder ¶ added in v5.6.3
type ContainerAuthenticatorBuilder struct {
ContainerAuthenticator
}
ContainerAuthenticatorBuilder is used to construct an instance of the ContainerAuthenticator
func NewContainerAuthenticatorBuilder ¶ added in v5.6.3
func NewContainerAuthenticatorBuilder() *ContainerAuthenticatorBuilder
NewContainerAuthenticatorBuilder returns a new builder struct that can be used to construct a ContainerAuthenticator instance.
func (*ContainerAuthenticatorBuilder) Build ¶ added in v5.6.3
func (builder *ContainerAuthenticatorBuilder) Build() (*ContainerAuthenticator, error)
Build() returns a validated instance of the ContainerAuthenticator with the config that was set in the builder.
func (*ContainerAuthenticatorBuilder) SetCRTokenFilename ¶ added in v5.6.3
func (builder *ContainerAuthenticatorBuilder) SetCRTokenFilename(s string) *ContainerAuthenticatorBuilder
SetCRTokenFilename sets the CRTokenFilename field in the builder.
func (*ContainerAuthenticatorBuilder) SetClient ¶ added in v5.6.3
func (builder *ContainerAuthenticatorBuilder) SetClient(client *http.Client) *ContainerAuthenticatorBuilder
SetClient sets the Client field in the builder.
func (*ContainerAuthenticatorBuilder) SetClientIDSecret ¶ added in v5.6.3
func (builder *ContainerAuthenticatorBuilder) SetClientIDSecret(clientID, clientSecret string) *ContainerAuthenticatorBuilder
SetClientIDSecret sets the ClientID and ClientSecret fields in the builder.
func (*ContainerAuthenticatorBuilder) SetDisableSSLVerification ¶ added in v5.6.3
func (builder *ContainerAuthenticatorBuilder) SetDisableSSLVerification(b bool) *ContainerAuthenticatorBuilder
SetDisableSSLVerification sets the DisableSSLVerification field in the builder.
func (*ContainerAuthenticatorBuilder) SetHeaders ¶ added in v5.6.3
func (builder *ContainerAuthenticatorBuilder) SetHeaders(headers map[string]string) *ContainerAuthenticatorBuilder
SetHeaders sets the Headers field in the builder.
func (*ContainerAuthenticatorBuilder) SetIAMProfileID ¶ added in v5.6.3
func (builder *ContainerAuthenticatorBuilder) SetIAMProfileID(s string) *ContainerAuthenticatorBuilder
SetIAMProfileID sets the IAMProfileID field in the builder.
func (*ContainerAuthenticatorBuilder) SetIAMProfileName ¶ added in v5.6.3
func (builder *ContainerAuthenticatorBuilder) SetIAMProfileName(s string) *ContainerAuthenticatorBuilder
SetIAMProfileName sets the IAMProfileName field in the builder.
func (*ContainerAuthenticatorBuilder) SetScope ¶ added in v5.6.3
func (builder *ContainerAuthenticatorBuilder) SetScope(s string) *ContainerAuthenticatorBuilder
SetScope sets the Scope field in the builder.
func (*ContainerAuthenticatorBuilder) SetURL ¶ added in v5.6.3
func (builder *ContainerAuthenticatorBuilder) SetURL(s string) *ContainerAuthenticatorBuilder
SetURL sets the URL field in the builder.
type DetailedResponse ¶
type DetailedResponse struct { // The HTTP status code associated with the response. StatusCode int `yaml:"status_code"` // The HTTP headers contained in the response. Headers http.Header `yaml:"headers"` // Result - this field will contain the result of the operation (obtained from the response body). // // If the operation was successful and the response body contains a JSON response, it is un-marshalled // into an object of the appropriate type (defined by the particular operation), and the Result field will contain // this response object. If there was an error while un-marshalling the JSON response body, then the RawResult field // will be set to the byte array containing the response body. // // Alternatively, if the generated SDK code passes in a result object which is an io.ReadCloser instance, // the JSON un-marshalling step is bypassed and the response body is simply returned in the Result field. // This scenario would occur in a situation where the SDK would like to provide a streaming model for large JSON // objects. // // If the operation was successful and the response body contains a non-JSON response, // the Result field will be an instance of io.ReadCloser that can be used by generated SDK code // (or the application) to read the response data. // // If the operation was unsuccessful and the response body contains a JSON error response, // this field will contain an instance of map[string]interface{} which is the result of un-marshalling the // response body as a "generic" JSON object. // If the JSON response for an unsuccessful operation could not be properly un-marshalled, then the // RawResult field will contain the raw response body. Result interface{} `yaml:"result,omitempty"` // This field will contain the raw response body as a byte array under these conditions: // 1) there was a problem un-marshalling a JSON response body - // either for a successful or unsuccessful operation. // 2) the operation was unsuccessful, and the response body contains a non-JSON response. RawResult []byte `yaml:"raw_result,omitempty"` }
DetailedResponse holds the response information received from the server.
func (*DetailedResponse) GetHeaders ¶
func (response *DetailedResponse) GetHeaders() http.Header
GetHeaders returns the headers
func (*DetailedResponse) GetRawResult ¶
func (response *DetailedResponse) GetRawResult() []byte
GetRawResult returns the raw response body as a byte array.
func (*DetailedResponse) GetResult ¶
func (response *DetailedResponse) GetResult() interface{}
GetResult returns the result from the service
func (*DetailedResponse) GetResultAsMap ¶
func (response *DetailedResponse) GetResultAsMap() (map[string]interface{}, bool)
GetResultAsMap returns the result as a map (generic JSON object), if the DetailedResponse.Result field contains an instance of a map.
func (*DetailedResponse) GetStatusCode ¶
func (response *DetailedResponse) GetStatusCode() int
GetStatusCode returns the HTTP status code
func (*DetailedResponse) String ¶
func (response *DetailedResponse) String() string
type Errors ¶
type Errors struct {
Errors []Error `json:"errors,omitempty"`
}
Errors is a struct used to hold an array of errors received in an operation response.
type FileWithMetadata ¶ added in v5.4.0
type FileWithMetadata struct { // The data / content for the file. Data io.ReadCloser `json:"data" validate:"required"` // The filename of the file. Filename *string `json:"filename,omitempty"` // The content type of the file. ContentType *string `json:"content_type,omitempty"` }
FileWithMetadata : A file with its associated metadata.
func NewFileWithMetadata ¶ added in v5.4.0
func NewFileWithMetadata(data io.ReadCloser) (model *FileWithMetadata, err error)
NewFileWithMetadata : Instantiate FileWithMetadata (Generic Model Constructor)
type FormData ¶
type FormData struct {
// contains filtered or unexported fields
}
FormData stores information for form data.
type HTTPProblem ¶ added in v5.16.0
type HTTPProblem struct { *IBMProblem // OperationID identifies the operation of an API // that the failed request was made to. OperationID string // Response contains the full HTTP error response // returned as a result of the failed request, // including the body and all headers. Response *DetailedResponse }
HTTPProblem provides a type suited to problems that occur as the result of an HTTP request. It extends the base "IBMProblem" type with fields to store information about the HTTP request/response.
func (*HTTPProblem) GetConsoleMessage ¶ added in v5.16.0
func (e *HTTPProblem) GetConsoleMessage() string
GetConsoleMessage returns all public fields of the problem, formatted in YAML.
func (*HTTPProblem) GetConsoleOrderedMaps ¶ added in v5.16.0
func (e *HTTPProblem) GetConsoleOrderedMaps() *OrderedMaps
GetConsoleOrderedMaps returns an ordered-map representation of an HTTPProblem instance suited for a console message.
func (*HTTPProblem) GetDebugMessage ¶ added in v5.16.0
func (e *HTTPProblem) GetDebugMessage() string
GetDebugMessage returns all information about the problem, formatted in YAML.
func (*HTTPProblem) GetDebugOrderedMaps ¶ added in v5.16.0
func (e *HTTPProblem) GetDebugOrderedMaps() *OrderedMaps
GetDebugOrderedMaps returns an ordered-map representation of an HTTPProblem instance, with additional information suited for a debug message.
func (*HTTPProblem) GetID ¶ added in v5.16.0
func (e *HTTPProblem) GetID() string
GetID returns the computed identifier, computed from the "Component", "discriminator", and "OperationID" fields, as well as the status code of the stored response and the identifier of the "causedBy" problem, if it exists.
func (*HTTPProblem) Is ¶ added in v5.16.2
func (e *HTTPProblem) Is(target error) bool
Is allows an HTTPProblem instance to be compared against another error for equality. An HTTPProblem is considered equal to another error if 1) the error is also a Problem and 2) it has the same ID (i.e. it is the same problem scenario).
type IBMProblem ¶ added in v5.16.0
type IBMProblem struct { // Summary is the informative, user-friendly message that describes // the problem and what caused it. Summary string // Component is a structure providing information about the actual // component that the problem occurred in: the name of the component // and the version of the component being used with the problem occurred. // Examples of components include cloud services, SDK clients, the IBM // Terraform Provider, etc. For programming libraries, the Component name // should match the module name for the library (i.e. the name a user // would use to install it). Component *ProblemComponent // Severity represents the severity level of the problem, // e.g. error, warning, or info. Severity problemSeverity // contains filtered or unexported fields }
IBMProblem holds the base set of fields that all problem types should include. It is geared more towards embedding in other structs than towards use on its own.
func IBMErrorf ¶ added in v5.16.0
func IBMErrorf(err error, component *ProblemComponent, summary, discriminator string) *IBMProblem
IBMErrorf creates and returns a new instance of an IBMProblem struct with "error" level severity. It is primarily meant for embedding IBMProblem structs in other types.
func (*IBMProblem) Error ¶ added in v5.16.0
func (e *IBMProblem) Error() string
Error returns the problem's message and implements the native "error" interface.
func (*IBMProblem) GetBaseSignature ¶ added in v5.16.0
func (e *IBMProblem) GetBaseSignature() string
GetBaseSignature provides a convenient way of retrieving the fields needed to compute the hash that are common to every kind of problem.
func (*IBMProblem) GetCausedBy ¶ added in v5.16.0
func (e *IBMProblem) GetCausedBy() Problem
GetCausedBy returns the underlying "causedBy" problem, if it exists.
func (*IBMProblem) Unwrap ¶ added in v5.16.0
func (e *IBMProblem) Unwrap() []error
Unwrap implements an interface the native Go "errors" package uses to check for embedded problems in a given problem instance. IBM problem types are not embedded in the traditional sense, but they chain previous problem instances together with the "causedBy" field. This allows error interface instances to be cast into any of the problem types in the chain using the native "errors.As" function. This can be useful for, as an example, extracting an HTTPProblem from the chain if it exists. Note that this Unwrap method returns only the chain of "caused by" problems; it does not include the error instance the method is called on - that is looked at separately by the "errors" package in functions like "As".
type IamAssumeAuthenticator ¶ added in v5.18.0
type IamAssumeAuthenticator struct {
// contains filtered or unexported fields
}
IamAssumeAuthenticator obtains an IAM access token using the IAM "get-token" operation's "assume" grant type. The authenticator obtains an initial IAM access token from a user-supplied apikey, then exchanges this initial IAM access token for another IAM access token that has "assumed the identity" of the specified trusted profile.
The resulting IAM access token is added to each outbound request in an Authorization header of the form:
Authorization: Bearer <access-token>
func (*IamAssumeAuthenticator) Authenticate ¶ added in v5.18.0
func (authenticator *IamAssumeAuthenticator) Authenticate(request *http.Request) error
Authenticate adds IAM authentication information to the request.
The IAM access token will be added to the request's headers in the form:
Authorization: Bearer <access-token>
func (*IamAssumeAuthenticator) AuthenticationType ¶ added in v5.18.0
func (*IamAssumeAuthenticator) AuthenticationType() string
AuthenticationType returns the authentication type for this authenticator.
func (*IamAssumeAuthenticator) GetToken ¶ added in v5.18.0
func (authenticator *IamAssumeAuthenticator) GetToken() (string, error)
GetToken returns an access token to be used in an Authorization header. Whenever a new token is needed (when a token doesn't yet exist, needs to be refreshed, or the existing token has expired), a new access token is fetched from the token server.
func (*IamAssumeAuthenticator) NewBuilder ¶ added in v5.18.0
func (authenticator *IamAssumeAuthenticator) NewBuilder() *IamAssumeAuthenticatorBuilder
NewBuilder returns an IamAssumeAuthenticatorBuilder instance configured with the contents of "authenticator".
func (*IamAssumeAuthenticator) RequestToken ¶ added in v5.18.0
func (authenticator *IamAssumeAuthenticator) RequestToken() (*IamTokenServerResponse, error)
RequestToken fetches a new access token from the token server and returns the response structure.
func (*IamAssumeAuthenticator) Validate ¶ added in v5.18.0
func (authenticator *IamAssumeAuthenticator) Validate() error
Validate will verify the authenticator's configuration.
type IamAssumeAuthenticatorBuilder ¶ added in v5.18.0
type IamAssumeAuthenticatorBuilder struct { // Properties needed to construct an IamAuthenticator instance. IamAuthenticator // Properties needed to construct an IamAssumeAuthenticator instance. IamAssumeAuthenticator }
IamAssumeAuthenticatorBuilder is used to construct an IamAssumeAuthenticator instance.
func NewIamAssumeAuthenticatorBuilder ¶ added in v5.18.0
func NewIamAssumeAuthenticatorBuilder() *IamAssumeAuthenticatorBuilder
NewIamAssumeAuthenticatorBuilder returns a new builder struct that can be used to construct an IamAssumeAuthenticator instance.
func (*IamAssumeAuthenticatorBuilder) Build ¶ added in v5.18.0
func (builder *IamAssumeAuthenticatorBuilder) Build() (*IamAssumeAuthenticator, error)
Build() returns a validated instance of the IamAssumeAuthenticator with the config that was set in the builder.
func (*IamAssumeAuthenticatorBuilder) SetApiKey ¶ added in v5.18.0
func (builder *IamAssumeAuthenticatorBuilder) SetApiKey(s string) *IamAssumeAuthenticatorBuilder
SetApiKey sets the ApiKey field in the builder.
func (*IamAssumeAuthenticatorBuilder) SetClient ¶ added in v5.18.0
func (builder *IamAssumeAuthenticatorBuilder) SetClient(client *http.Client) *IamAssumeAuthenticatorBuilder
SetClient sets the Client field in the builder.
func (*IamAssumeAuthenticatorBuilder) SetClientIDSecret ¶ added in v5.18.0
func (builder *IamAssumeAuthenticatorBuilder) SetClientIDSecret(clientID, clientSecret string) *IamAssumeAuthenticatorBuilder
SetClientIDSecret sets the ClientId and ClientSecret fields in the builder.
func (*IamAssumeAuthenticatorBuilder) SetDisableSSLVerification ¶ added in v5.18.0
func (builder *IamAssumeAuthenticatorBuilder) SetDisableSSLVerification(b bool) *IamAssumeAuthenticatorBuilder
SetDisableSSLVerification sets the DisableSSLVerification field in the builder.
func (*IamAssumeAuthenticatorBuilder) SetHeaders ¶ added in v5.18.0
func (builder *IamAssumeAuthenticatorBuilder) SetHeaders(headers map[string]string) *IamAssumeAuthenticatorBuilder
SetHeaders sets the Headers field in the builder.
func (*IamAssumeAuthenticatorBuilder) SetIAMAccountID ¶ added in v5.18.0
func (builder *IamAssumeAuthenticatorBuilder) SetIAMAccountID(s string) *IamAssumeAuthenticatorBuilder
SetIAMAccountID sets the iamAccountID field in the builder.
func (*IamAssumeAuthenticatorBuilder) SetIAMProfileCRN ¶ added in v5.18.0
func (builder *IamAssumeAuthenticatorBuilder) SetIAMProfileCRN(s string) *IamAssumeAuthenticatorBuilder
SetIAMProfileCRN sets the iamProfileCRN field in the builder.
func (*IamAssumeAuthenticatorBuilder) SetIAMProfileID ¶ added in v5.18.0
func (builder *IamAssumeAuthenticatorBuilder) SetIAMProfileID(s string) *IamAssumeAuthenticatorBuilder
SetIAMProfileID sets the iamProfileID field in the builder.
func (*IamAssumeAuthenticatorBuilder) SetIAMProfileName ¶ added in v5.18.0
func (builder *IamAssumeAuthenticatorBuilder) SetIAMProfileName(s string) *IamAssumeAuthenticatorBuilder
SetIAMProfileName sets the iamProfileName field in the builder.
func (*IamAssumeAuthenticatorBuilder) SetScope ¶ added in v5.18.0
func (builder *IamAssumeAuthenticatorBuilder) SetScope(s string) *IamAssumeAuthenticatorBuilder
SetScope sets the Scope field in the builder.
func (*IamAssumeAuthenticatorBuilder) SetURL ¶ added in v5.18.0
func (builder *IamAssumeAuthenticatorBuilder) SetURL(s string) *IamAssumeAuthenticatorBuilder
SetURL sets the url field in the builder.
type IamAuthenticator ¶
type IamAuthenticator struct { // The apikey used to fetch the bearer token from the IAM token server. // You must specify either ApiKey or RefreshToken. ApiKey string // The refresh token used to fetch the bearer token from the IAM token server. // You must specify either ApiKey or RefreshToken. // If this property is specified, then you also must supply appropriate values // for the ClientId and ClientSecret properties (i.e. they must be the same // values that were used to obtain the refresh token). RefreshToken string // The URL representing the IAM token server's endpoint; If not specified, // a suitable default value will be used [optional]. URL string // If neither field is specified, then no Authorization header will be sent // with token server requests [optional]. These fields are optional, but must // be specified together. ClientId string ClientSecret string // A flag that indicates whether verification of the server's SSL certificate // should be disabled; defaults to false [optional]. DisableSSLVerification bool // [Optional] The "scope" to use when fetching the bearer token from the // IAM token server. This can be used to obtain an access token // with a specific scope. Scope string // [Optional] A set of key/value pairs that will be sent as HTTP headers in requests // made to the token server. Headers map[string]string // [Optional] The http.Client object used to invoke token server requests. // If not specified by the user, a suitable default Client will be constructed. Client *http.Client // contains filtered or unexported fields }
IamAuthenticator uses an apikey to obtain an IAM access token, and adds the access token to requests via an Authorization header of the form:
Authorization: Bearer <access-token>
func NewIamAuthenticator ¶
func NewIamAuthenticator(apiKey string, url string, clientId string, clientSecret string, disableSSLVerification bool, headers map[string]string) (*IamAuthenticator, error)
NewIamAuthenticator constructs a new IamAuthenticator instance. Deprecated - use the IamAuthenticatorBuilder instead.
func (*IamAuthenticator) Authenticate ¶
func (authenticator *IamAuthenticator) Authenticate(request *http.Request) error
Authenticate adds IAM authentication information to the request.
The IAM access token will be added to the request's headers in the form:
Authorization: Bearer <access-token>
func (*IamAuthenticator) AuthenticationType ¶
func (*IamAuthenticator) AuthenticationType() string
AuthenticationType returns the authentication type for this authenticator.
func (*IamAuthenticator) GetToken ¶ added in v5.5.1
func (authenticator *IamAuthenticator) GetToken() (string, error)
GetToken: returns an access token to be used in an Authorization header. Whenever a new token is needed (when a token doesn't yet exist, needs to be refreshed, or the existing token has expired), a new access token is fetched from the token server.
func (*IamAuthenticator) RequestToken ¶
func (authenticator *IamAuthenticator) RequestToken() (*IamTokenServerResponse, error)
RequestToken fetches a new access token from the token server.
func (*IamAuthenticator) Validate ¶
func (authenticator *IamAuthenticator) Validate() error
Validate the authenticator's configuration.
Ensures that the ApiKey and RefreshToken properties are mutually exclusive, and that the ClientId and ClientSecret properties are mutually inclusive.
type IamAuthenticatorBuilder ¶ added in v5.9.0
type IamAuthenticatorBuilder struct {
IamAuthenticator
}
IamAuthenticatorBuilder is used to construct an IamAuthenticator instance.
func NewIamAuthenticatorBuilder ¶ added in v5.9.0
func NewIamAuthenticatorBuilder() *IamAuthenticatorBuilder
NewIamAuthenticatorBuilder returns a new builder struct that can be used to construct an IamAuthenticator instance.
func (*IamAuthenticatorBuilder) Build ¶ added in v5.9.0
func (builder *IamAuthenticatorBuilder) Build() (*IamAuthenticator, error)
Build() returns a validated instance of the IamAuthenticator with the config that was set in the builder.
func (*IamAuthenticatorBuilder) SetApiKey ¶ added in v5.9.0
func (builder *IamAuthenticatorBuilder) SetApiKey(s string) *IamAuthenticatorBuilder
SetApiKey sets the ApiKey field in the builder.
func (*IamAuthenticatorBuilder) SetClient ¶ added in v5.9.0
func (builder *IamAuthenticatorBuilder) SetClient(client *http.Client) *IamAuthenticatorBuilder
SetClient sets the Client field in the builder.
func (*IamAuthenticatorBuilder) SetClientIDSecret ¶ added in v5.9.0
func (builder *IamAuthenticatorBuilder) SetClientIDSecret(clientID, clientSecret string) *IamAuthenticatorBuilder
SetClientIDSecret sets the ClientId and ClientSecret fields in the builder.
func (*IamAuthenticatorBuilder) SetDisableSSLVerification ¶ added in v5.9.0
func (builder *IamAuthenticatorBuilder) SetDisableSSLVerification(b bool) *IamAuthenticatorBuilder
SetDisableSSLVerification sets the DisableSSLVerification field in the builder.
func (*IamAuthenticatorBuilder) SetHeaders ¶ added in v5.9.0
func (builder *IamAuthenticatorBuilder) SetHeaders(headers map[string]string) *IamAuthenticatorBuilder
SetHeaders sets the Headers field in the builder.
func (*IamAuthenticatorBuilder) SetRefreshToken ¶ added in v5.9.0
func (builder *IamAuthenticatorBuilder) SetRefreshToken(s string) *IamAuthenticatorBuilder
SetRefreshToken sets the RefreshToken field in the builder.
func (*IamAuthenticatorBuilder) SetScope ¶ added in v5.9.0
func (builder *IamAuthenticatorBuilder) SetScope(s string) *IamAuthenticatorBuilder
SetScope sets the Scope field in the builder.
func (*IamAuthenticatorBuilder) SetURL ¶ added in v5.9.0
func (builder *IamAuthenticatorBuilder) SetURL(s string) *IamAuthenticatorBuilder
SetURL sets the URL field in the builder.
type IamTokenServerResponse ¶
type IamTokenServerResponse struct { AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` TokenType string `json:"token_type"` ExpiresIn int64 `json:"expires_in"` Expiration int64 `json:"expiration"` }
IamTokenServerResponse : This struct models a response received from the token server.
type Logger ¶
type Logger interface { Log(level LogLevel, format string, inserts ...interface{}) Error(format string, inserts ...interface{}) Warn(format string, inserts ...interface{}) Info(format string, inserts ...interface{}) Debug(format string, inserts ...interface{}) SetLogLevel(level LogLevel) GetLogLevel() LogLevel IsLogLevelEnabled(level LogLevel) bool }
Logger is the logging interface implemented and used by the Go core library. Users of the library can supply their own implementation by calling SetLogger().
type MCSPAuthenticator ¶ added in v5.15.0
type MCSPAuthenticator struct { // [Required] The apikey used to fetch the bearer token from the token server. ApiKey string // [Required] The endpoint base URL for the token server. URL string // [Optional] A flag that indicates whether verification of the token server's SSL certificate // should be disabled; defaults to false. DisableSSLVerification bool // [Optional] A set of key/value pairs that will be sent as HTTP headers in requests // made to the token server. Headers map[string]string // [Optional] The http.Client object used to invoke token server requests. // If not specified by the user, a suitable default Client will be constructed. Client *http.Client // contains filtered or unexported fields }
MCSPAuthenticator uses an apikey to obtain an access token, and adds the access token to requests via an Authorization header of the form: "Authorization: Bearer <access-token>"
func (*MCSPAuthenticator) Authenticate ¶ added in v5.15.0
func (authenticator *MCSPAuthenticator) Authenticate(request *http.Request) error
Authenticate adds the Authorization header to the request. The value will be of the form: "Authorization: Bearer <bearer-token>""
func (*MCSPAuthenticator) AuthenticationType ¶ added in v5.15.0
func (*MCSPAuthenticator) AuthenticationType() string
AuthenticationType returns the authentication type for this authenticator.
func (*MCSPAuthenticator) GetToken ¶ added in v5.15.0
func (authenticator *MCSPAuthenticator) GetToken() (string, error)
GetToken: returns an access token to be used in an Authorization header. Whenever a new token is needed (when a token doesn't yet exist, needs to be refreshed, or the existing token has expired), a new access token is fetched from the token server.
func (*MCSPAuthenticator) RequestToken ¶ added in v5.15.0
func (authenticator *MCSPAuthenticator) RequestToken() (*MCSPTokenServerResponse, error)
RequestToken fetches a new access token from the token server.
func (*MCSPAuthenticator) Validate ¶ added in v5.15.0
func (authenticator *MCSPAuthenticator) Validate() error
Validate the authenticator's configuration.
Ensures that the ApiKey and URL properties are both specified.
type MCSPAuthenticatorBuilder ¶ added in v5.15.0
type MCSPAuthenticatorBuilder struct {
MCSPAuthenticator
}
MCSPAuthenticatorBuilder is used to construct an MCSPAuthenticator instance.
func NewMCSPAuthenticatorBuilder ¶ added in v5.15.0
func NewMCSPAuthenticatorBuilder() *MCSPAuthenticatorBuilder
NewMCSPAuthenticatorBuilder returns a new builder struct that can be used to construct an MCSPAuthenticator instance.
func (*MCSPAuthenticatorBuilder) Build ¶ added in v5.15.0
func (builder *MCSPAuthenticatorBuilder) Build() (*MCSPAuthenticator, error)
Build() returns a validated instance of the MCSPAuthenticator with the config that was set in the builder.
func (*MCSPAuthenticatorBuilder) SetApiKey ¶ added in v5.15.0
func (builder *MCSPAuthenticatorBuilder) SetApiKey(s string) *MCSPAuthenticatorBuilder
SetApiKey sets the ApiKey field in the builder.
func (*MCSPAuthenticatorBuilder) SetClient ¶ added in v5.15.0
func (builder *MCSPAuthenticatorBuilder) SetClient(client *http.Client) *MCSPAuthenticatorBuilder
SetClient sets the Client field in the builder.
func (*MCSPAuthenticatorBuilder) SetDisableSSLVerification ¶ added in v5.15.0
func (builder *MCSPAuthenticatorBuilder) SetDisableSSLVerification(b bool) *MCSPAuthenticatorBuilder
SetDisableSSLVerification sets the DisableSSLVerification field in the builder.
func (*MCSPAuthenticatorBuilder) SetHeaders ¶ added in v5.15.0
func (builder *MCSPAuthenticatorBuilder) SetHeaders(headers map[string]string) *MCSPAuthenticatorBuilder
SetHeaders sets the Headers field in the builder.
func (*MCSPAuthenticatorBuilder) SetURL ¶ added in v5.15.0
func (builder *MCSPAuthenticatorBuilder) SetURL(s string) *MCSPAuthenticatorBuilder
SetURL sets the URL field in the builder.
type MCSPTokenServerResponse ¶ added in v5.15.0
type MCSPTokenServerResponse struct { Token string `json:"token"` TokenType string `json:"token_type"` ExpiresIn int64 `json:"expires_in"` }
MCSPTokenServerResponse : This struct models a response received from the token server.
type ModelUnmarshaller ¶
type ModelUnmarshaller func(rawInput map[string]json.RawMessage, result interface{}) error
ModelUnmarshaller defines the interface for a generated Unmarshal<model>() function, which is used by the various "UnmarshalModel" functions below to unmarshal an instance of the user-defined model type.
Parameters: rawInput: a map[string]json.RawMessage that is assumed to contain an instance of the model type.
result: the unmarshal destination. This should be a **<model> (i.e. a ptr to a ptr to a model instance). A new instance of the model is constructed by the unmarshaller function and is returned through the ptr passed in as 'result'.
type NoAuthAuthenticator ¶
type NoAuthAuthenticator struct { }
NoAuthAuthenticator is simply a placeholder implementation of the Authenticator interface that performs no authentication. This might be useful in testing/debugging situations.
func NewNoAuthAuthenticator ¶
func NewNoAuthAuthenticator() (*NoAuthAuthenticator, error)
func (*NoAuthAuthenticator) Authenticate ¶
func (this *NoAuthAuthenticator) Authenticate(request *http.Request) error
func (NoAuthAuthenticator) AuthenticationType ¶
func (NoAuthAuthenticator) AuthenticationType() string
func (NoAuthAuthenticator) Validate ¶
func (NoAuthAuthenticator) Validate() error
type OrderableProblem ¶ added in v5.16.0
type OrderableProblem interface { GetConsoleOrderedMaps() *OrderedMaps GetDebugOrderedMaps() *OrderedMaps }
OrderableProblem provides an interface for retrieving ordered representations of problems in order to print YAML messages with a controlled ordering of the fields.
type OrderedMaps ¶ added in v5.16.0
type OrderedMaps struct {
// contains filtered or unexported fields
}
OrderedMaps provides a wrapper around the yaml package's MapItem type and provides convenience functionality beyond what would be available with the MapSlice type, which is similar. It enables the ordering of fields in a map for controlling the order of keys in the printed YAML strings.
func NewOrderedMaps ¶ added in v5.16.0
func NewOrderedMaps() *OrderedMaps
NewOrderedMaps initializes and returns a new instance of OrderedMaps.
func (*OrderedMaps) Add ¶ added in v5.16.0
func (m *OrderedMaps) Add(key string, value interface{})
Add appends a key/value pair to the ordered list of maps.
func (*OrderedMaps) GetMaps ¶ added in v5.16.0
func (m *OrderedMaps) GetMaps() []yaml.MapItem
GetMaps returns the actual list of ordered maps stored in the OrderedMaps instance. Each element is MapItem type, which will be serialized by the yaml package in a special way that allows the ordering of fields in the YAML.
type Problem ¶ added in v5.16.0
type Problem interface { // GetConsoleMessage returns a message suited to the practitioner // or end user. It should tell the user what went wrong, and why, // without unnecessary implementation details. GetConsoleMessage() string // GetDebugMessage returns a message suited to the developer, in // order to assist in debugging. It should give enough information // for the developer to identify the root cause of the issue. GetDebugMessage() string // GetID returns an identifier or code for a given problem. It is computed // from the attributes of the problem, so that the same problem scenario // will always have the same ID, even when encountered by different users. GetID() string // Error returns the message associated with a given problem and guarantees // every instance of Problem also implements the native "error" interface. Error() string }
Problem is an interface that describes the common behavior of custom IBM problem message types.
type ProblemComponent ¶ added in v5.16.0
ProblemComponent is a structure that holds information about a given component.
func NewProblemComponent ¶ added in v5.16.0
func NewProblemComponent(name, version string) *ProblemComponent
type RequestBuilder ¶
type RequestBuilder struct { Method string URL *url.URL Header http.Header Body io.Reader Query map[string][]string Form map[string][]FormData // EnableGzipCompression indicates whether or not request bodies // should be gzip-compressed. // This field has no effect on response bodies. // If enabled, the Body field will be gzip-compressed and // the "Content-Encoding" header will be added to the request with the // value "gzip". EnableGzipCompression bool // contains filtered or unexported fields }
RequestBuilder is used to build an HTTP Request instance.
func NewRequestBuilder ¶
func NewRequestBuilder(method string) *RequestBuilder
NewRequestBuilder initiates a new request.
func (*RequestBuilder) AddFormData ¶
func (requestBuilder *RequestBuilder) AddFormData(fieldName string, fileName string, contentType string, contents interface{}) *RequestBuilder
AddFormData adds a new mime part (constructed from the input parameters) to the request's multi-part form.
func (*RequestBuilder) AddHeader ¶
func (requestBuilder *RequestBuilder) AddHeader(name string, value string) *RequestBuilder
AddHeader adds a header name and value to the request.
func (*RequestBuilder) AddQuery ¶
func (requestBuilder *RequestBuilder) AddQuery(name string, value string) *RequestBuilder
AddQuery adds a query parameter name and value to the request.
func (*RequestBuilder) AddQuerySlice ¶
func (requestBuilder *RequestBuilder) AddQuerySlice(param string, slice interface{}) (err error)
AddQuerySlice converts the passed in slice 'slice' by calling the ConverSlice method, and adds the converted slice to the request's query string. An error is returned when conversion fails.
func (*RequestBuilder) Build ¶
func (requestBuilder *RequestBuilder) Build() (req *http.Request, err error)
Build builds an HTTP Request object from this RequestBuilder instance.
func (*RequestBuilder) ConstructHTTPURL ¶
func (requestBuilder *RequestBuilder) ConstructHTTPURL(serviceURL string, pathSegments []string, pathParameters []string) (*RequestBuilder, error)
ConstructHTTPURL creates a properly-encoded URL with path parameters. This function returns an error if the serviceURL is "" or is an invalid URL string (e.g. ":<badscheme>").
func (*RequestBuilder) ResolveRequestURL ¶
func (requestBuilder *RequestBuilder) ResolveRequestURL(serviceURL string, path string, pathParams map[string]string) (*RequestBuilder, error)
ResolveRequestURL creates a properly-encoded URL with path params. This function returns an error if the serviceURL is "" or is an invalid URL string (e.g. ":<badscheme>"). Parameters: serviceURL - the base URL associated with the service endpoint (e.g. "https://myservice.cloud.ibm.com") path - the unresolved path string (e.g. "/resource/{resource_id}/type/{type_id}") pathParams - a map containing the path params, keyed by the path param base name (e.g. {"type_id": "type-1", "resource_id": "res-123-456-789-abc"}) The resulting request URL: "https://myservice.cloud.ibm.com/resource/res-123-456-789-abc/type/type-1"
func (*RequestBuilder) SetBodyContent ¶
func (requestBuilder *RequestBuilder) SetBodyContent(contentType string, jsonContent interface{}, jsonPatchContent interface{}, nonJSONContent interface{}) (builder *RequestBuilder, err error)
SetBodyContent sets the body content from one of three different sources.
func (*RequestBuilder) SetBodyContentForMultipart ¶
func (requestBuilder *RequestBuilder) SetBodyContentForMultipart(contentType string, content interface{}, writer io.Writer) error
SetBodyContentForMultipart sets the body content for a part in a multi-part form.
func (*RequestBuilder) SetBodyContentJSON ¶
func (requestBuilder *RequestBuilder) SetBodyContentJSON(bodyContent interface{}) (*RequestBuilder, error)
SetBodyContentJSON sets the body content from a JSON structure.
func (*RequestBuilder) SetBodyContentStream ¶
func (requestBuilder *RequestBuilder) SetBodyContentStream(bodyContent io.Reader) (*RequestBuilder, error)
SetBodyContentStream sets the body content from an io.Reader instance.
func (*RequestBuilder) SetBodyContentString ¶
func (requestBuilder *RequestBuilder) SetBodyContentString(bodyContent string) (*RequestBuilder, error)
SetBodyContentString sets the body content from a string.
func (*RequestBuilder) WithContext ¶
func (requestBuilder *RequestBuilder) WithContext(ctx context.Context) *RequestBuilder
WithContext sets "ctx" as the Context to be associated with the http.Request instance that will be constructed by the Build() method.
type SDKLoggerImpl ¶
type SDKLoggerImpl struct {
// contains filtered or unexported fields
}
SDKLoggerImpl is the Go core's implementation of the Logger interface. This logger contains two instances of Go's log.Logger interface which are used to perform message logging. "infoLogger" is used to log info/warn/debug messages. If specified as nil, then a default log.Logger instance that uses stdout will be created and used for "infoLogger". "errorLogger" is used to log error messages. If specified as nil, then a default log.Logger instance that uses stderr will be created and used for "errorLogger".
func NewLogger ¶
NewLogger constructs an SDKLoggerImpl instance with the specified logging level enabled. The "infoLogger" parameter is the log.Logger instance to be used to log info/warn/debug messages. If specified as nil, then a default log.Logger instance that writes messages to "stdout" will be used. The "errorLogger" parameter is the log.Logger instance to be used to log error messages. If specified as nil, then a default log.Logger instance that writes messages to "stderr" will be used.
func (*SDKLoggerImpl) Debug ¶
func (l *SDKLoggerImpl) Debug(format string, inserts ...interface{})
Debug logs a message at level "Debug"
func (*SDKLoggerImpl) Error ¶
func (l *SDKLoggerImpl) Error(format string, inserts ...interface{})
Error logs a message at level "Error"
func (*SDKLoggerImpl) GetLogLevel ¶
func (l *SDKLoggerImpl) GetLogLevel() LogLevel
GetLogLevel sets level to be the current logging level
func (*SDKLoggerImpl) Info ¶
func (l *SDKLoggerImpl) Info(format string, inserts ...interface{})
Info logs a message at level "Info"
func (*SDKLoggerImpl) IsLogLevelEnabled ¶
func (l *SDKLoggerImpl) IsLogLevelEnabled(level LogLevel) bool
IsLogLevelEnabled returns true iff the logger's current logging level indicates that 'level' is enabled.
func (*SDKLoggerImpl) Log ¶
func (l *SDKLoggerImpl) Log(level LogLevel, format string, inserts ...interface{})
Log will log the specified message on the appropriate log.Logger instance if "level" is currently enabled.
func (*SDKLoggerImpl) SetLogLevel ¶
func (l *SDKLoggerImpl) SetLogLevel(level LogLevel)
SetLogLevel sets level to be the current logging level
func (*SDKLoggerImpl) Warn ¶
func (l *SDKLoggerImpl) Warn(format string, inserts ...interface{})
Warn logs a message at level "Warn"
type SDKProblem ¶ added in v5.16.0
type SDKProblem struct { *IBMProblem // Function provides the name of the in-code // function or method in which the problem // occurred. Function string // contains filtered or unexported fields }
SDKProblem provides a type suited to problems that occur in SDK projects. It extends the base "IBMProblem" type with a field to store the function being called when the problem occurs.
func SDKErrorf ¶ added in v5.16.0
func SDKErrorf(err error, summary, discriminator string, component *ProblemComponent) *SDKProblem
SDKErrorf creates and returns a new instance of "SDKProblem" with "error" level severity.
func (*SDKProblem) GetConsoleMessage ¶ added in v5.16.0
func (e *SDKProblem) GetConsoleMessage() string
GetConsoleMessage returns all public fields of the problem, formatted in YAML.
func (*SDKProblem) GetConsoleOrderedMaps ¶ added in v5.16.0
func (e *SDKProblem) GetConsoleOrderedMaps() *OrderedMaps
GetConsoleOrderedMaps returns an ordered-map representation of an SDKProblem instance suited for a console message.
func (*SDKProblem) GetDebugMessage ¶ added in v5.16.0
func (e *SDKProblem) GetDebugMessage() string
GetDebugMessage returns all information about the problem, formatted in YAML.
func (*SDKProblem) GetDebugOrderedMaps ¶ added in v5.16.0
func (e *SDKProblem) GetDebugOrderedMaps() *OrderedMaps
GetDebugOrderedMaps returns an ordered-map representation of an SDKProblem instance, with additional information suited for a debug message.
func (*SDKProblem) GetID ¶ added in v5.16.0
func (e *SDKProblem) GetID() string
GetID returns the computed identifier, computed from the "Component", "discriminator", and "Function" fields, as well as the identifier of the "causedBy" problem, if it exists.
func (*SDKProblem) Is ¶ added in v5.16.2
func (e *SDKProblem) Is(target error) bool
Is allows an SDKProblem instance to be compared against another error for equality. An SDKProblem is considered equal to another error if 1) the error is also a Problem and 2) it has the same ID (i.e. it is the same problem scenario).
type ServiceOptions ¶
type ServiceOptions struct { // This is the base URL associated with the service instance. This value will // be combined with the paths for each operation to form the request URL // [required]. URL string // Authenticator holds the authenticator implementation to be used by the // service instance to authenticate outbound requests, typically by adding the // HTTP "Authorization" header. Authenticator Authenticator // EnableGzipCompression indicates whether or not request bodies // should be gzip-compressed. // This field has no effect on response bodies. // If enabled, the Body field will be gzip-compressed and // the "Content-Encoding" header will be added to the request with the // value "gzip". EnableGzipCompression bool }
ServiceOptions is a struct of configuration values for a service.
type VpcInstanceAuthenticator ¶ added in v5.8.0
type VpcInstanceAuthenticator struct { // [optional] The CRN of the linked trusted IAM profile to be used as the identity of the compute resource. // At most one of IAMProfileCRN or IAMProfileID may be specified. If neither one is specified, then // the default IAM profile defined for the compute resource will be used. // Default value: "" IAMProfileCRN string // [optional] The ID of the linked trusted IAM profile to be used when obtaining the IAM access token. // At most one of IAMProfileCRN or IAMProfileID may be specified. If neither one is specified, then // the default IAM profile defined for the compute resource will be used. // Default value: "" IAMProfileID string // [optional] The VPC Instance Metadata Service's base endpoint URL. // Default value: "http://169.254.169.254" URL string // [optional] The http.Client object used to interact with the VPC Instance Metadata Service API. // If not specified by the user, a suitable default Client will be constructed. Client *http.Client // contains filtered or unexported fields }
VpcInstanceAuthenticator implements an authentication scheme in which it retrieves an "instance identity token" and exchanges that for an IAM access token using the VPC Instance Metadata Service API which is available on the local compute resource (VM). The instance identity token is similar to an IAM apikey, except that it is managed automatically by the compute resource provider (VPC). The resulting IAM access token is then added to outbound requests in an Authorization header of the form:
Authorization: Bearer <access-token>
func (*VpcInstanceAuthenticator) Authenticate ¶ added in v5.8.0
func (authenticator *VpcInstanceAuthenticator) Authenticate(request *http.Request) error
Authenticate adds IAM authentication information to the request.
The IAM access token will be added to the request's headers in the form:
Authorization: Bearer <access-token>
func (*VpcInstanceAuthenticator) AuthenticationType ¶ added in v5.8.0
func (*VpcInstanceAuthenticator) AuthenticationType() string
AuthenticationType returns the authentication type for this authenticator.
func (*VpcInstanceAuthenticator) GetToken ¶ added in v5.8.0
func (authenticator *VpcInstanceAuthenticator) GetToken() (string, error)
GetToken returns an IAM access token to be used in an Authorization header. Whenever a new IAM access token is needed (when a token doesn't yet exist or the existing token has expired), a new IAM access token is fetched from the token server.
func (*VpcInstanceAuthenticator) RequestToken ¶ added in v5.8.0
func (authenticator *VpcInstanceAuthenticator) RequestToken() (iamTokenResponse *IamTokenServerResponse, err error)
RequestToken will use the VPC Instance Metadata Service to (1) retrieve a fresh instance identity token and then (2) exchange that for an IAM access token.
func (*VpcInstanceAuthenticator) Validate ¶ added in v5.8.0
func (authenticator *VpcInstanceAuthenticator) Validate() error
Validate the authenticator's configuration.
Ensures that one of IAMProfileName or IAMProfileID are specified, and the ClientId and ClientSecret pair are mutually inclusive.
type VpcInstanceAuthenticatorBuilder ¶ added in v5.8.0
type VpcInstanceAuthenticatorBuilder struct {
VpcInstanceAuthenticator
}
VpcInstanceAuthenticatorBuilder is used to construct an instance of the VpcInstanceAuthenticator
func NewVpcInstanceAuthenticatorBuilder ¶ added in v5.8.0
func NewVpcInstanceAuthenticatorBuilder() *VpcInstanceAuthenticatorBuilder
NewVpcInstanceAuthenticatorBuilder returns a new builder struct that can be used to construct a VpcInstanceAuthenticator instance.
func (*VpcInstanceAuthenticatorBuilder) Build ¶ added in v5.8.0
func (builder *VpcInstanceAuthenticatorBuilder) Build() (*VpcInstanceAuthenticator, error)
Build() returns a validated instance of the VpcInstanceAuthenticator with the config that was set in the builder.
func (*VpcInstanceAuthenticatorBuilder) SetClient ¶ added in v5.8.0
func (builder *VpcInstanceAuthenticatorBuilder) SetClient(client *http.Client) *VpcInstanceAuthenticatorBuilder
SetClient sets the Client field in the builder.
func (*VpcInstanceAuthenticatorBuilder) SetIAMProfileCRN ¶ added in v5.8.0
func (builder *VpcInstanceAuthenticatorBuilder) SetIAMProfileCRN(s string) *VpcInstanceAuthenticatorBuilder
SetIAMProfileCRN sets the IAMProfileCRN field in the builder.
func (*VpcInstanceAuthenticatorBuilder) SetIAMProfileID ¶ added in v5.8.0
func (builder *VpcInstanceAuthenticatorBuilder) SetIAMProfileID(s string) *VpcInstanceAuthenticatorBuilder
SetIAMProfileID sets the IAMProfileID field in the builder.
func (*VpcInstanceAuthenticatorBuilder) SetURL ¶ added in v5.8.0
func (builder *VpcInstanceAuthenticatorBuilder) SetURL(s string) *VpcInstanceAuthenticatorBuilder
SetURL sets the URL field in the builder.
Source Files ¶
- authentication_error.go
- authenticator.go
- authenticator_factory.go
- base_service.go
- basic_authenticator.go
- bearer_token_authenticator.go
- config_utils.go
- constants.go
- container_authenticator.go
- cp4d_authenticator.go
- datetime.go
- detailed_response.go
- doc.go
- file_with_metadata.go
- gzip.go
- http_problem.go
- iam_assume_authenticator.go
- iam_authenticator.go
- ibm_problem.go
- jwt_utils.go
- log.go
- mcsp_authenticator.go
- noauth_authenticator.go
- ordered_maps.go
- parameterized_url.go
- problem.go
- problem_utils.go
- request_builder.go
- sdk_problem.go
- sdk_problem_utils.go
- unmarshal_v2.go
- utils.go
- version.go
- vpc_instance_authenticator.go