# Packages
Package auth provides supporting functions and structs for authentication.
# Functions
Bool returns a pointer to the provided bool.
CloseBodyIfValid closes the body of an http response if the response and the body are valid.
CloseLogFile close the logging file and return error.
ComposingConfigurationProvider creates a composing configuration provider with the given slice of configuration providers A composing provider will return the configuration of the first provider that has the required property if no provider has the property it will return an error.
ConfigCircuitBreakerFromEnvVar is used for checking the circuit breaker environment variable setting, default value is nil.
ConfigCircuitBreakerFromGlobalVar is used for checking if global circuitBreakerSetting is configured, the priority is higher than cb env var.
ConfigurationProviderEnvironmentVariables creates a ConfigurationProvider from a uniform set of environment variables starting with a prefix The env variables should look like: [prefix]_private_key_path, [prefix]_tenancy_ocid, [prefix]_user_ocid, [prefix]_fingerprint [prefix]_region.
ConfigurationProviderFromFile creates a configuration provider from a configuration file by reading the "DEFAULT" profile.
ConfigurationProviderFromFileWithProfile creates a configuration provider from a configuration file and the given profile.
CustomProfileConfigProvider returns the config provider of given profile.
Debug logs v if debug mode is set.
Debugf logs v with the provided format if debug mode is set.
Debugln logs v appending a new line if debug mode is set.
DefaultBaseClientWithSigner creates a default base client with a given signer.
DefaultBodyHeaders list of default body headers that is used in signing.
DefaultCircuitBreakerSetting is used for set circuit breaker with default config.
DefaultCircuitBreakerSettingWithServiceName is used for set circuit breaker with default config.
DefaultConfigProvider returns the default config provider.
DefaultGenericHeaders list of default generic headers that is used in signing.
DefaultRequestSigner creates a signer with default parameters.
DefaultRetryPolicy is a helper method that assembles and returns a return policy that is defined to be a default one The default retry policy will retry on (409, IncorrectState), (429, TooManyRequests) and any 5XX errors except (501, MethodNotImplemented) The default retry behavior is using exponential backoff with jitter, the maximum wait time is 30s plus 1s jitter The maximum cumulative backoff after all 8 attempts have been made is about 1.5 minutes.
DefaultRetryPolicyWithoutEventualConsistency is a helper method that assembles and returns a return policy that is defined to be a default one The default retry policy will retry on (409, IncorrectState), (429, TooManyRequests) and any 5XX errors except (501, MethodNotImplemented) It will not retry on errors affected by eventual consistency.
DefaultShouldRetryOperation is the function that should be used for RetryPolicy.ShouldRetryOperation when not taking eventual consistency into account.
EnableInstanceMetadataServiceLookup provides the interface to lookup IMDS region info.
EventuallyConsistentRetryPolicy is a helper method that assembles and returns a return policy that is defined to be a default one plus dealing with errors affected by eventual consistency.
EventuallyConsistentShouldRetryOperation is the function that should be used for RetryPolicy.ShouldRetryOperation when taking eventual consistency into account.
Float32 returns a pointer to the provided float32.
Float64 returns a pointer to the provided float64.
GetBackoffWithoutJitter calculates the backoff without jitter for the attempt, given the retry policy.
GetBodyHash creates a base64 string from the hash of body the request.
GetEventuallyConsistentBackoffWithoutJitter calculates the backoff without jitter for the attempt, given the retry policy and dealing with eventually consistent effects.
GetMaximumCumulativeBackoffWithoutJitter calculates the maximum backoff without jitter, according to the retry policy, if every retry attempt is made.
GetMaximumCumulativeEventuallyConsistentBackoffWithoutJitter calculates the maximum backoff without jitter, according to the retry policy and taking eventually consistent effects into account, if every retry attempt is made.
HTTPRequestMarshaller marshals a structure to an http request using tag values in the struct The marshaller tag should like the following type A struct { ANumber string `contributesTo="query" name="number"` TheBody `contributesTo="body"` } where the contributesTo tag can be: header, path, query, body and the 'name' tag is the name of the value used in the http request(not applicable for path) If path is specified as part of the tag, the values are appened to the url path in the order they appear in the structure The current implementation only supports primitive types, except for the body tag, which needs a struct type.
IfDebug executes closure if debug is enabled.
IfInfo executes closure if info is enabled.
InitializeEcContextFile initializes the EcContext variable to be kept in a timestamp file, protected by a lock file.
InitializeEcContextFromEnvVar initializes the EcContext variable as configured in the OCI_GO_SDK_EC_CONFIG environment variable.
InitializeEcContextInProcess initializes the EcContext variable to be in-process only.
Int returns a pointer to the provided int.
Int64 returns a pointer to the provided int64.
IsCircuitBreakerError validates if an error's text is Open state ErrOpenState or HalfOpen state ErrTooManyRequests.
IsConfigurationProviderValid Tests all parts of the configuration provider do not return an error, this method will not check AuthType(), since authType() is not required to be there.
IsEnvVarFalse is used for checking if an environment variable is explicitly set to false, otherwise would set it true by default.
IsEnvVarTrue is used for checking if an environment variable is explicitly set to true, otherwise would set it true by default.
IsErrorAffectedByEventualConsistency returns true if the error is affected by eventual consistency.
IsErrorRetryableByDefault returns true if the error is retryable by OCI default retry policy.
IsNetworkError validates if an error is a net.Error and check if it's temporary or timeout.
IsServiceError returns false if the error is not service side, otherwise true additionally it returns an interface representing the ServiceError.
Logf logs v with the provided format.
Logln logs v appending a new line at the endDeprecated.
MakeDefaultHTTPRequest creates the basic http request with the necessary headers set.
MakeDefaultHTTPRequestWithTaggedStruct creates an http request from an struct with tagged fields, see HTTPRequestMarshaller for more information.
MakeDefaultHTTPRequestWithTaggedStructAndExtraHeaders creates an http request from an struct with tagged fields, see HTTPRequestMarshaller for more information.
NewCircuitBreaker is used for initialing specified circuit breaker configuration with base client.
NewCircuitBreakerSettingWithOptions is a helper method to assemble a CircuitBreakerSetting object.
NewClientWithConfig Create a new client with a configuration provider, the configuration provider will be used for the default signer as well as reading the region This function does not check for valid regions to implement forward compatibility.
NewClientWithOboToken Create a new client that will use oboToken for auth.
NewGoCircuitBreaker is a function to initialize a CircuitBreaker object with the specified configuration Add the interface, to allow the user directly use the 3P gobreaker.Setting's params.
NewOciCircuitBreaker is used for initializing specified oci circuit breaker configuration with circuit breaker settings.
NewOCIOperationResponse assembles an OCI Operation Response object.
NewOCIOperationResponseExtended assembles an OCI Operation Response object, with the value for the EndOfWindowTime, BackoffScalingFactor, and InitialAttemptTime set.
NewOCIReadSeekCloser constructs OCIReadSeekCloser, the only input is binary request body.
NewRawConfigurationProvider will create a ConfigurationProvider with the arguments of the function.
NewRetryPolicy is a helper method for assembling a Retry Policy object.
NewRetryPolicyWithEventualConsistencyUnlimitedAttempts is a helper method for assembling a Retry Policy object.
NewRetryPolicyWithOptions is a helper method for assembling a Retry Policy object.
NewSDKDateFromString parses the dateString into SDKDate.
NewSignerFromOCIRequestSigner creates a copy of the request signer and attaches the new SignerBodyHashPredicate returns an error if the passed signer is not of type ociRequestSigner.
NoCircuitBreakerSetting is used for disable Circuit Breaker.
NoRetryPolicy is a helper method that assembles and returns a return policy that indicates an operation should never be retried (the operation is performed exactly once).
PointerString prints the values of pointers in a structProducing a human friendly string for an struct with pointers.useful when debugging the values of a struct.
PrivateKeyFromBytes is a helper function that will produce a RSA private key from bytes.
PrivateKeyFromBytesWithPassword is a helper function that will produce a RSA private key from bytes and a password.
ReplaceWithValuesFromRetryPolicy is an option for NewRetryPolicyWithOptions that copies over all settings from another RetryPolicy.
RequestSigner creates a signer that utilizes the specified headers for signing and the default predicate for using the body of the request as part of the signature.
RequestSignerExcludeBody creates a signer without hash the body.
RequestSignerWithBodyHashingPredicate creates a signer that utilizes the specified headers for signing, as well as a predicate for using the body of the request and bodyHeaders parameter as part of the signature.
Retry is a package-level operation that executes the retryable request using the specified operation and retry policy.
RetryToken generates a retry token that must be included on any request passed to the Retry method.
String returns a pointer to the provided string.
StringToRegion convert a string to Region type.
Uint returns a pointer to the provided uint.
UnmarshalResponse hydrates the fields of a struct with the values of a http response, guided by the field tags.
UnmarshalResponseWithPolymorphicBody similar to UnmarshalResponse but assumes the body of the response contains polymorphic json.
UpdateRequestBinaryBody updates the http request's body once it is binary request and the request body is seekable if the content length is zero, no need to update request body(since it's already been set to http.Nody).
Version returns semantic version of the sdk.
WithCloseStateWindow is the option for NewCircuitBreaker that sets the closeStateWindow.
WithConditionalOption is an option for NewRetryPolicyWithOptions that enables or disables another option.
WithEventualConsistency is the option for NewRetryPolicyWithOptions that enables considering eventual backoff for the policy.
WithExponentialBackoff is an option for NewRetryPolicyWithOptions that sets the exponential backoff base, minimum and maximum sleep between attempts, and next duration function.
WithFailureRateThreshold is the option for NewCircuitBreaker that sets the failureRateThreshold.
WithFixedBackoff is an option for NewRetryPolicyWithOptions that sets the backoff to always be exactly the same value.
WithHistoryCount to set the number of failed responses.
WithIsEnabled is the option for NewCircuitBreaker that sets the isEnabled.
WithMaximumNumberAttempts is the option for NewRetryPolicyWithOptions that sets the maximum number of attempts.
WithMinimumRequests is the option for NewCircuitBreaker that sets the minimumRequests.
WithName is the option for NewCircuitBreaker that sets the Name.
WithNextDuration is the option for NewRetryPolicyWithOptions that sets the function for computing the next backoff duration.
WithOpenStateWindow is the option for NewCircuitBreaker that sets the openStateWindow.
WithServiceName is the option for NewCircuitBreaker that sets the ServiceName.
WithShouldRetryOperation is the option for NewRetryPolicyWithOptions that sets the function that checks whether retries should be performed.
WithSuccessStatCodeMap is the option for NewCircuitBreaker that sets the successStatCodeMap.
WithSuccessStatErrCodeMap is the option for NewCircuitBreaker that sets the successStatErrCodeMap.
WithUnlimitedAttempts is the option for NewRetryPolicyWithOptions that sets unlimited number of attempts, but it needs to set a MaximumCumulativeBackoffWithoutJitter duration.
# Constants
CircuitBreakerDefaultClosedWindow is the default value of closeStateWindow, which is the cyclic period of the closed state.
CircuitBreakerDefaultFailureRateThreshold is the requests failure rate which calculates in at most 120 seconds, once reaches to this rate, the circuit breaker state changes from closed to open.
CircuitBreakerDefaultResetTimeout is the default value of openStateWindow, which is the wait time before setting the breaker to halfOpen state from open state.
CircuitBreakerDefaultVolumeThreshold is the default value of minimumRequests in closed status.
DefaultCircuitBreakerHistoryCount is the default count of failed response history in circuit breaker.
DefaultCircuitBreakerName is the name of the circuit breaker.
DefaultCircuitBreakerServiceName is the servicename of the circuit breaker.
DefaultHostURLTemplate The default url template for service hosts.
EndpointTemplateForRegionWithDot Environment Variable.
File is the EC communication mode that uses a file to communicate the end-of-window timestamp using a file visible across processes.
InProcess is the default EC communication mode which only communicates the end-of-window timestamp inside the same process.
InstancePrincipal is used for instance principle auth type.
InstancePrincipalDelegationToken is used for instance principle delegation token auth type.
OciGoSdkEcConfigEnvVarName contains the name of the environment variable that can be used to configure the eventual consistency (EC) communication mode.
RegionAFJohannesburg1 region Johannesburg.
RegionAPChiyoda1 region Chiyoda.
RegionAPChuncheon1 region Chuncheon.
RegionAPDccCanberra1 region Canberra.
RegionAPHyderabad1 region Hyderabad.
RegionAPIbaraki1 region Ibaraki.
RegionAPMelbourne1 region Melbourne.
RegionAPMumbai1 region Mumbai.
RegionAPOsaka1 region Osaka.
RegionAPSeoul1 region Seoul.
RegionAPSingapore1 region Singapore.
RegionAPSydney1 region Sydney.
RegionAPTokyo1 region Tokyo.
RegionCAMontreal1 region Montreal.
RegionCAToronto1 region Toronto.
RegionEUAmsterdam1 region Amsterdam.
RegionEUMarseille1 region Marseille.
RegionEUMilan1 region Milan.
RegionEUStockholm1 region Stockholm.
RegionEUZurich1 region Zurich.
RegionFRA region Frankfurt.
RegionIAD region Ashburn.
RegionILJerusalem1 region Jerusalem.
RegionLHR region London.
RegionMEAbudhabi1 region Abudhabi.
RegionMEDccMuscat1 region Muscat.
RegionMEDubai1 region Dubai.
RegionMEJeddah1 region Jeddah.
RegionPHX region Phoenix.
RegionSASantiago1 region Santiago.
RegionSASaopaulo1 region Saopaulo.
RegionSAVinhedo1 region Vinhedo.
RegionSJC1 region Sanjose.
RegionUKCardiff1 region Cardiff.
RegionUKGovCardiff1 gov region Cardiff.
RegionUKGovLondon1 gov region London.
RegionUSGovAshburn1 gov region Ashburn.
RegionUSGovChicago1 gov region Chicago.
RegionUSGovPhoenix1 gov region Phoenix.
RegionUSLangley1 region Langley.
RegionUSLuke1 region Luke.
0.
UnknownAuthenticationType is used for none meaningful auth type.
UnlimitedNumAttemptsValue is the value for indicating unlimited attempts for reaching success.
UserPrincipal is default auth type.
UsingExpectHeaderEnvVar is the key to determine whether expect 100-continue is enabled or not.
# Variables
DeadlineExceededByBackoff is the error returned by Call() when GetNextDuration() returns a time.Duration that would force the user to wait past the request deadline before re-issuing a request.
EcContext contains the information about the end of the eventually consistent window for this process.
GlobalCircuitBreakerSetting is global level circuit breaker setting, it would impact all services, the precedence is lower than client level circuit breaker.
GlobalRetry is user defined global level retry policy, it would impact all services, the precedence is lower than user defined client/request level retry policy.
# Structs
AuthConfig is used for getting auth related paras in config file.
BaseClient struct implements all basic operations to call oci web services.
CircuitBreakerSetting wraps all exposed configurable params of circuit breaker.
ClientCallDetails a set of settings used by the a single Call operation of the http Client.
CustomClientConfiguration contains configurations set at client level, currently it only includes RetryPolicy.
EventuallyConsistentContext contains the information about the end of the eventually consistent window.
NonSeekableRequestRetryFailure is the error returned when the request is with binary request body, and is configured retry, but the request body is not retryable.
OciCircuitBreaker wraps all exposed configurable params of circuit breaker and 3P gobreaker CircuirBreaker.
OCIOperationResponse represents the output of an OCIOperation, with additional context of error message and operation attempt number.
OCIReadSeekCloser is a thread-safe io.ReadSeekCloser to prevent racing with retrying binary requests.
RequestMetadata is metadata about an OCIRequest.
ResponseHistory wraps the response params.
RetryPolicy is the class that holds all relevant information for retrying operations.
SDKDate a struct that parses/renders to/from json using only date information.
SDKTime a struct that parses/renders to/from json using RFC339 date-time information.
StatErrCode is a type which wraps error's statusCode and errorCode from service end.
# Interfaces
ConfigurationProvider wraps information about the account owner.
HTTPRequestDispatcher wraps the execution of a http request, it is generally implemented by http.Client.Do, but can be customized for testing.
HTTPRequestSigner the interface to sign a request.
KeyProvider interface that wraps information about the key's account owner.
OCIRequest is any request made to an OCI service.
OCIResponse is the response from issuing a request to an OCI service.
OCIRetryableRequest represents a request that can be reissued according to the specified policy.
PolymorphicJSONUnmarshaler is the interface to unmarshal polymorphic json payloads.
RefreshableConfigurationProvider the interface to identity if the config provider is refreshable.
ServiceError models all potential errors generated the service call.
# Type aliases
AuthenticationType for auth.
CircuitBreakerOption is the type of the options for NewCircuitBreakerWithOptions.
EcMode is the eventual consistency (EC) communication mode used.
OCIOperation is the generalization of a request-response cycle undergone by an OCI service.
Region type for regions.
RequestInterceptor function used to customize the request before calling the underlying service.
RetryPolicyOption is the type of the options for NewRetryPolicy.
SignerBodyHashPredicate a function that allows to disable/enable body hashing of requests and headers associated with body content.