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/master/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 CopyMap(m map[string]interface{}) map[string]interface{}
- func Float32Ptr(literal float32) *float32
- func Float64Ptr(literal float64) *float64
- func GetCurrentTime() int64
- func HasBadFirstOrLastChar(str string) bool
- func Int64Ptr(literal int64) *int64
- func IsJSONMimeType(mimeType string) bool
- func IsJSONPatchMimeType(mimeType string) bool
- func PrettyPrint(result interface{}, resultName string)
- func StringNilMapper(s *string) string
- func StringPtr(literal string) *string
- func SystemInfo() string
- func UnmarshalAny(m map[string]interface{}, propertyName string) (result interface{}, err error)
- func UnmarshalAnyMap(m map[string]interface{}, propertyName string) (result map[string]interface{}, err error)
- func UnmarshalAnyMapSlice(m map[string]interface{}, propertyName string) (slice []map[string]interface{}, err error)
- func UnmarshalAnySlice(m map[string]interface{}, propertyName string) (slice []interface{}, err error)
- func UnmarshalBool(m map[string]interface{}, propertyName string) (result *bool, err error)
- func UnmarshalBoolMap(m map[string]interface{}, propertyName string) (result map[string]bool, err error)
- func UnmarshalBoolMapSlice(m map[string]interface{}, propertyName string) (slice []map[string]bool, err error)
- func UnmarshalBoolSlice(m map[string]interface{}, propertyName string) (slice []bool, err error)
- func UnmarshalByteArray(m map[string]interface{}, propertyName string) (result *[]byte, err error)
- func UnmarshalByteArrayMap(m map[string]interface{}, propertyName string) (result map[string][]byte, err error)
- func UnmarshalByteArrayMapSlice(m map[string]interface{}, propertyName string) (slice []map[string][]byte, err error)
- func UnmarshalByteArraySlice(m map[string]interface{}, propertyName string) (slice [][]byte, err error)
- func UnmarshalDate(m map[string]interface{}, propertyName string) (result *strfmt.Date, err error)
- func UnmarshalDateMap(m map[string]interface{}, propertyName string) (result map[string]strfmt.Date, err error)
- func UnmarshalDateMapSlice(m map[string]interface{}, propertyName string) (slice []map[string]strfmt.Date, err error)
- func UnmarshalDateSlice(m map[string]interface{}, propertyName string) (slice []strfmt.Date, err error)
- func UnmarshalDateTime(m map[string]interface{}, propertyName string) (result *strfmt.DateTime, err error)
- func UnmarshalDateTimeMap(m map[string]interface{}, propertyName string) (result map[string]strfmt.DateTime, err error)
- func UnmarshalDateTimeMapSlice(m map[string]interface{}, propertyName string) (slice []map[string]strfmt.DateTime, err error)
- func UnmarshalDateTimeSlice(m map[string]interface{}, propertyName string) (slice []strfmt.DateTime, err error)
- func UnmarshalFloat32(m map[string]interface{}, propertyName string) (result *float32, err error)
- func UnmarshalFloat32Map(m map[string]interface{}, propertyName string) (result map[string]float32, err error)
- func UnmarshalFloat32MapSlice(m map[string]interface{}, propertyName string) (slice []map[string]float32, err error)
- func UnmarshalFloat32Slice(m map[string]interface{}, propertyName string) (slice []float32, err error)
- func UnmarshalFloat64(m map[string]interface{}, propertyName string) (result *float64, err error)
- func UnmarshalFloat64Map(m map[string]interface{}, propertyName string) (result map[string]float64, err error)
- func UnmarshalFloat64MapSlice(m map[string]interface{}, propertyName string) (slice []map[string]float64, err error)
- func UnmarshalFloat64Slice(m map[string]interface{}, propertyName string) (slice []float64, err error)
- func UnmarshalInt64(m map[string]interface{}, propertyName string) (result *int64, err error)
- func UnmarshalInt64Map(m map[string]interface{}, propertyName string) (result map[string]int64, err error)
- func UnmarshalInt64MapSlice(m map[string]interface{}, propertyName string) (slice []map[string]int64, err error)
- func UnmarshalInt64Slice(m map[string]interface{}, propertyName string) (slice []int64, err error)
- func UnmarshalObject(m map[string]interface{}, propertyName string) (result map[string]interface{}, err error)
- func UnmarshalObjectSlice(m map[string]interface{}, propertyName string) (slice []map[string]interface{}, err error)
- func UnmarshalString(m map[string]interface{}, propertyName string) (result *string, err error)
- func UnmarshalStringMap(m map[string]interface{}, propertyName string) (result map[string]string, err error)
- func UnmarshalStringMapSlice(m map[string]interface{}, propertyName string) (slice []map[string]string, err error)
- func UnmarshalStringSlice(m map[string]interface{}, propertyName string) (slice []string, err error)
- func UnmarshalUUID(m map[string]interface{}, propertyName string) (result *strfmt.UUID, err error)
- func UnmarshalUUIDMap(m map[string]interface{}, propertyName string) (result map[string]strfmt.UUID, err error)
- func UnmarshalUUIDMapSlice(m map[string]interface{}, propertyName string) (slice []map[string]strfmt.UUID, err error)
- func UnmarshalUUIDSlice(m map[string]interface{}, propertyName string) (slice []strfmt.UUID, err error)
- func UserHomeDir() string
- func ValidateNotNil(object interface{}, errorMsg string) error
- func ValidateStruct(param interface{}, paramName string) error
- type Authenticator
- type BaseService
- func (service *BaseService) ConfigureService(serviceName string) error
- func (service *BaseService) DisableSSLVerification()
- func (service *BaseService) GetServiceURL() string
- func (service *BaseService) Request(req *http.Request, result interface{}) (detailedResponse *DetailedResponse, err error)
- func (service *BaseService) SetDefaultHeaders(headers http.Header)
- 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(userAgentString string)
- type BasicAuthenticator
- type BearerTokenAuthenticator
- type CloudPakForDataAuthenticator
- 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 FormData
- type IamAuthenticator
- type NoAuthAuthenticator
- 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) Build() (*http.Request, error)
- func (requestBuilder *RequestBuilder) ConstructHTTPURL(serviceURL string, pathSegments []string, pathParameters []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)
- type ServiceOptions
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_CP4D = "cp4d" // Service client properties. PROPNAME_SVC_URL = "URL" PROPNAME_SVC_DISABLE_SSL = "DISABLE_SSL" // 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_CLIENT_ID = "CLIENT_ID" PROPNAME_CLIENT_SECRET = "CLIENT_SECRET" // 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_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." )
const ( DEFAULT_IAM_URL = "https://iam.cloud.ibm.com/identity/token" DEFAULT_CONTENT_TYPE = "application/x-www-form-urlencoded" REQUEST_TOKEN_GRANT_TYPE = "urn:ibm:params:oauth:grant-type:apikey" REQUEST_TOKEN_RESPONSE_TYPE = "cloud_iam" )
IamAuthenticator-related constants.
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_TYPE = "Content-Type" FORM_URL_ENCODED_HEADER = "application/x-www-form-urlencoded" ERRORMSG_SERVICE_URL_MISSING = "The service URL is required." ERRORMSG_SERVICE_URL_INVALID = "There was an error parsing the service URL: %s" )
common headers
const (
PRE_AUTH_PATH = "/v1/preauth/validateAuth"
)
Constants for CP4D
Variables ¶
var Validate *validator.Validate
Validate is a shared validator instance used to perform validation of structs.
Functions ¶
func CopyMap ¶
CopyMap returns a shallow copy of the specified map. The returned map contains a copy of the mappings found in the original map, but uses values from the original map.
func Float32Ptr ¶
Float32Ptr returns a pointer to float32 literal.
func Float64Ptr ¶
Float64Ptr returns a pointer to float64 literal.
func HasBadFirstOrLastChar ¶
HasBadFirstOrLastChar checks if the string starts with `{` or `"` or ends with `}` or `"`.
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 PrettyPrint ¶
func PrettyPrint(result interface{}, resultName string)
PrettyPrint print pretty.
func StringNilMapper ¶
StringNilMapper de-references the parameter 's' and returns the result, or "" if 's' is nil.
func UnmarshalAny ¶ added in v3.2.0
UnmarshalAny retrieves the specified property from the map and returns it as a generic value (i.e. interface{}), or nil if the property wasn't found in the map.
func UnmarshalAnyMap ¶ added in v3.3.0
func UnmarshalAnyMap(m map[string]interface{}, propertyName string) (result map[string]interface{}, err error)
UnmarshalAnyMap retrieves the specified property from the map "m" and returns it as a map[string]interface{}, or nil if the property wasn't found in the map.
func UnmarshalAnyMapSlice ¶ added in v3.3.0
func UnmarshalAnyMapSlice(m map[string]interface{}, propertyName string) (slice []map[string]interface{}, err error)
UnmarshalAnyMapSlice retrieves the specified property from the map "m" and returns it as a []map[string]interface{}, or nil if the property wasn't found in the map.
func UnmarshalAnySlice ¶ added in v3.2.0
func UnmarshalAnySlice(m map[string]interface{}, propertyName string) (slice []interface{}, err error)
UnmarshalAnySlice retrieves the specified property from the map and returns it as a slice of generic values (i.e. []interface{}), or nil if the property wasn't found in the map.
func UnmarshalBool ¶
UnmarshalBool retrieves the specified property from the map and returns it as a bool or nil if the property wasn't found in the map.
func UnmarshalBoolMap ¶ added in v3.3.0
func UnmarshalBoolMap(m map[string]interface{}, propertyName string) (result map[string]bool, err error)
UnmarshalBoolMap retrieves the specified property from the map "m" and returns it as a map[string]bool, or nil if the property wasn't found in the map.
func UnmarshalBoolMapSlice ¶ added in v3.3.0
func UnmarshalBoolMapSlice(m map[string]interface{}, propertyName string) (slice []map[string]bool, err error)
UnmarshalBoolMapSlice retrieves the specified property from the map "m" and returns it as a []map[string]bool, or nil if the property wasn't found in the map.
func UnmarshalBoolSlice ¶
UnmarshalBoolSlice retrieves the specified property from the map and returns it as a bool slice or nil if the property wasn't found in the map.
func UnmarshalByteArray ¶
UnmarshalByteArray retrieves the specified property from the map and returns it as a byte array or nil if the property wasn't found in the map.
func UnmarshalByteArrayMap ¶ added in v3.3.0
func UnmarshalByteArrayMap(m map[string]interface{}, propertyName string) (result map[string][]byte, err error)
UnmarshalByteArrayMap retrieves the specified property from the map "m" and returns it as a map[string][]byte, or nil if the property wasn't found in the map.
func UnmarshalByteArrayMapSlice ¶ added in v3.3.0
func UnmarshalByteArrayMapSlice(m map[string]interface{}, propertyName string) (slice []map[string][]byte, err error)
UnmarshalByteArrayMapSlice retrieves the specified property from the map "m" and returns it as a []map[string][]byte, or nil if the property wasn't found in the map.
func UnmarshalByteArraySlice ¶
func UnmarshalByteArraySlice(m map[string]interface{}, propertyName string) (slice [][]byte, err error)
UnmarshalByteArraySlice retrieves the specified property from the map and returns it as a byte array slice or nil if the property wasn't found in the map.
func UnmarshalDate ¶
UnmarshalDate retrieves the specified property from the map and returns it as a Date or nil if the property wasn't found in the map.
func UnmarshalDateMap ¶ added in v3.3.0
func UnmarshalDateMap(m map[string]interface{}, propertyName string) (result map[string]strfmt.Date, err error)
UnmarshalDateMap retrieves the specified property from the map "m" and returns it as a map[string]strfmt.Date, or nil if the property wasn't found in the map.
func UnmarshalDateMapSlice ¶ added in v3.3.0
func UnmarshalDateMapSlice(m map[string]interface{}, propertyName string) (slice []map[string]strfmt.Date, err error)
UnmarshalDateMapSlice retrieves the specified property from the map "m" and returns it as a []map[string]strfmt.Date, or nil if the property wasn't found in the map.
func UnmarshalDateSlice ¶
func UnmarshalDateSlice(m map[string]interface{}, propertyName string) (slice []strfmt.Date, err error)
UnmarshalDateSlice retrieves the specified property from the map and returns it as a Date slice or nil if the property wasn't found in the map.
func UnmarshalDateTime ¶
func UnmarshalDateTime(m map[string]interface{}, propertyName string) (result *strfmt.DateTime, err error)
UnmarshalDateTime retrieves the specified property from the map and returns it as a DateTime or nil if the property wasn't found in the map.
func UnmarshalDateTimeMap ¶ added in v3.3.0
func UnmarshalDateTimeMap(m map[string]interface{}, propertyName string) (result map[string]strfmt.DateTime, err error)
UnmarshalDateTimeMap retrieves the specified property from the map "m" and returns it as a map[string]strfmt.DateTime, or nil if the property wasn't found in the map.
func UnmarshalDateTimeMapSlice ¶ added in v3.3.0
func UnmarshalDateTimeMapSlice(m map[string]interface{}, propertyName string) (slice []map[string]strfmt.DateTime, err error)
UnmarshalDateTimeMapSlice retrieves the specified property from the map "m" and returns it as a []map[string]strfmt.DateTime, or nil if the property wasn't found in the map.
func UnmarshalDateTimeSlice ¶
func UnmarshalDateTimeSlice(m map[string]interface{}, propertyName string) (slice []strfmt.DateTime, err error)
UnmarshalDateTimeSlice retrieves the specified property from the map and returns it as a DateTime slice or nil if the property wasn't found in the map.
func UnmarshalFloat32 ¶
UnmarshalFloat32 retrieves the specified property from the map and returns it as a float32 or nil if the property wasn't found in the map.
func UnmarshalFloat32Map ¶ added in v3.3.0
func UnmarshalFloat32Map(m map[string]interface{}, propertyName string) (result map[string]float32, err error)
UnmarshalFloat32Map retrieves the specified property from the map "m" and returns it as a map[string]float32, or nil if the property wasn't found in the map.
func UnmarshalFloat32MapSlice ¶ added in v3.3.0
func UnmarshalFloat32MapSlice(m map[string]interface{}, propertyName string) (slice []map[string]float32, err error)
UnmarshalFloat32MapSlice retrieves the specified property from the map "m" and returns it as a []map[string]float32, or nil if the property wasn't found in the map.
func UnmarshalFloat32Slice ¶
func UnmarshalFloat32Slice(m map[string]interface{}, propertyName string) (slice []float32, err error)
UnmarshalFloat32Slice retrieves the specified property from the map and returns it as a float32 slice or nil if the property wasn't found in the map.
func UnmarshalFloat64 ¶
UnmarshalFloat64 retrieves the specified property from the map and returns it as a float64 or nil if the property wasn't found in the map.
func UnmarshalFloat64Map ¶ added in v3.3.0
func UnmarshalFloat64Map(m map[string]interface{}, propertyName string) (result map[string]float64, err error)
UnmarshalFloat64Map retrieves the specified property from the map "m" and returns it as a map[string]float64, or nil if the property wasn't found in the map.
func UnmarshalFloat64MapSlice ¶ added in v3.3.0
func UnmarshalFloat64MapSlice(m map[string]interface{}, propertyName string) (slice []map[string]float64, err error)
UnmarshalFloat64MapSlice retrieves the specified property from the map "m" and returns it as a []map[string]float64, or nil if the property wasn't found in the map.
func UnmarshalFloat64Slice ¶
func UnmarshalFloat64Slice(m map[string]interface{}, propertyName string) (slice []float64, err error)
UnmarshalFloat64Slice retrieves the specified property from the map and returns it as a float64 slice or nil if the property wasn't found in the map.
func UnmarshalInt64 ¶
UnmarshalInt64 retrieves the specified property from the map and returns it as an int64 or nil if the property wasn't found in the map.
func UnmarshalInt64Map ¶ added in v3.3.0
func UnmarshalInt64Map(m map[string]interface{}, propertyName string) (result map[string]int64, err error)
UnmarshalInt64Map retrieves the specified property from the map "m" and returns it as a map[string]int64, or nil if the property wasn't found in the map.
func UnmarshalInt64MapSlice ¶ added in v3.3.0
func UnmarshalInt64MapSlice(m map[string]interface{}, propertyName string) (slice []map[string]int64, err error)
UnmarshalInt64MapSlice retrieves the specified property from the map "m" and returns it as a []map[string]int64, or nil if the property wasn't found in the map.
func UnmarshalInt64Slice ¶
UnmarshalInt64Slice retrieves the specified property from the map and returns it as an int64 slice or nil if the property wasn't found in the map.
func UnmarshalObject ¶
func UnmarshalObject(m map[string]interface{}, propertyName string) (result map[string]interface{}, err error)
UnmarshalObject retrieves the specified property from the map and returns it as a generic object (i.e. map[string]interface{}), or nil if the property wasn't found in the map.
func UnmarshalObjectSlice ¶
func UnmarshalObjectSlice(m map[string]interface{}, propertyName string) (slice []map[string]interface{}, err error)
UnmarshalObjectSlice retrieves the specified property from the map and returns it as a slice of generic objects (i.e. []map[string]interface{}), or nil if the property wasn't found in the map.
func UnmarshalString ¶
UnmarshalString retrieves the specified property from the map and returns it as a string or nil if the property wasn't found in the map.
func UnmarshalStringMap ¶ added in v3.3.0
func UnmarshalStringMap(m map[string]interface{}, propertyName string) (result map[string]string, err error)
UnmarshalStringMap retrieves the specified property from the map "m" and returns it as a map[string]string, or nil if the property wasn't found in the map.
func UnmarshalStringMapSlice ¶ added in v3.3.0
func UnmarshalStringMapSlice(m map[string]interface{}, propertyName string) (slice []map[string]string, err error)
UnmarshalStringMapSlice retrieves the specified property from the map "m" and returns it as a []map[string]string, or nil if the property wasn't found in the map.
func UnmarshalStringSlice ¶
func UnmarshalStringSlice(m map[string]interface{}, propertyName string) (slice []string, err error)
UnmarshalStringSlice retrieves the specified property from the map and returns it as a string slice or nil if the property wasn't found in the map.
func UnmarshalUUID ¶
UnmarshalUUID retrieves the specified property from the map and returns it as a UUID or nil if the property wasn't found in the map.
func UnmarshalUUIDMap ¶ added in v3.3.0
func UnmarshalUUIDMap(m map[string]interface{}, propertyName string) (result map[string]strfmt.UUID, err error)
UnmarshalUUIDMap retrieves the specified property from the map "m" and returns it as a map[string]strfmt.UUID, or nil if the property wasn't found in the map.
func UnmarshalUUIDMapSlice ¶ added in v3.3.0
func UnmarshalUUIDMapSlice(m map[string]interface{}, propertyName string) (slice []map[string]strfmt.UUID, err error)
UnmarshalUUIDMapSlice retrieves the specified property from the map "m" and returns it as a []map[string]strfmt.UUID, or nil if the property wasn't found in the map.
func UnmarshalUUIDSlice ¶
func UnmarshalUUIDSlice(m map[string]interface{}, propertyName string) (slice []strfmt.UUID, err error)
UnmarshalUUIDSlice retrieves the specified property from the map and returns it as a UUID slice or nil if the property wasn't found in the map.
func ValidateNotNil ¶
ValidateNotNil returns the specified error if 'object' is nil, nil otherwise.
func ValidateStruct ¶
ValidateStruct validates 'param' (assumed to be a struct) according to the annotations attached to its fields.
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) ConfigureService ¶
func (service *BaseService) ConfigureService(serviceName string) error
ConfigureService updates the service with external configuration values.
func (*BaseService) DisableSSLVerification ¶
func (service *BaseService) DisableSSLVerification()
DisableSSLVerification skips SSL verification.
func (*BaseService) GetServiceURL ¶
func (service *BaseService) GetServiceURL() string
GetServiceURL returns the service URL.
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.
func (*BaseService) SetDefaultHeaders ¶
func (service *BaseService) SetDefaultHeaders(headers http.Header)
SetDefaultHeaders sets HTTP headers to be sent in every request.
func (*BaseService) SetHTTPClient ¶
func (service *BaseService) SetHTTPClient(client *http.Client)
SetHTTPClient updates the client handling the requests.
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(userAgentString 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 (this *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 (this 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 (this *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 (this 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]. Password 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 a username and password pair to obtain a suitable bearer token, 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.
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) 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 DetailedResponse ¶
type DetailedResponse struct { // The HTTP status code associated with the response. StatusCode int // The HTTP headers contained in the response. Headers http.Header // 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{} // 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 }
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 Error ¶
type Error struct {
Message string `json:"message,omitempty"`
}
Error is a struct used to represent a single error received in an operation response.
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 FormData ¶
type FormData struct {
// contains filtered or unexported fields
}
FormData stores information for form data.
type IamAuthenticator ¶
type IamAuthenticator struct { // The apikey used to fetch the bearer token from the IAM token server // [required]. ApiKey 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 // 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. ClientSecret string // A flag that indicates whether verification of the server's SSL certificate // should be disabled; defaults to false [optional]. 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 }
IamAuthenticator uses an apikey to obtain a suitable bearer token value, and adds the bearer token to requests via an Authorization header of the form:
Authorization: Bearer <bearer-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.
func (*IamAuthenticator) Authenticate ¶
func (authenticator *IamAuthenticator) Authenticate(request *http.Request) error
Authenticate adds IAM authentication information to the request.
The IAM bearer token will be added to the request's headers in the form:
Authorization: Bearer <bearer-token>
func (IamAuthenticator) AuthenticationType ¶
func (IamAuthenticator) AuthenticationType() string
AuthenticationType returns the authentication type for this authenticator.
func (IamAuthenticator) Validate ¶
func (this IamAuthenticator) Validate() error
Validate the authenticator's configuration.
Ensures the ApiKey is valid, and the ClientId and ClientSecret pair are mutually inclusive.
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 RequestBuilder ¶
type RequestBuilder struct { Method string URL *url.URL Header http.Header Body io.Reader Query map[string][]string Form map[string][]FormData }
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) Build ¶
func (requestBuilder *RequestBuilder) Build() (*http.Request, 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) 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.
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 }
ServiceOptions is a struct of configuration values for a service.