Documentation
¶
Index ¶
- func DefaultRetryAfter() time.Duration
- type Auth
- func (client *Auth) AuthenticateClientCertificate(ctx context.Context, scopes []string) (string, time.Time, error)
- func (client *Auth) AuthenticateClientSecret(ctx context.Context, scopes []string) (string, time.Time, error)
- func (client *Auth) AuthenticateOIDC(ctx context.Context, scopes []string) (string, time.Time, error)
- func (client *Auth) AuthenticateUsingCli(ctx context.Context, scopes []string) (string, time.Time, error)
- func (client *Auth) GetTokenForScopes(ctx context.Context, scopes []string) (*string, error)
- type Client
- func (client *Client) DoWaitForLifecycleOperationStatus(ctx context.Context, response *Response) (*LifecycleDto, error)
- func (client *Client) Execute(ctx context.Context, scopes []string, method, url string, headers http.Header, ...) (*Response, error)
- func (client *Client) GetConfig() *config.ProviderConfig
- func (client *Client) SleepWithContext(ctx context.Context, duration time.Duration) error
- type LifecycleDto
- type LifecycleLinkDto
- type LifecycleLinksDto
- type LifecycleRequestedByDto
- type LifecycleStageDto
- type LifecycleStateDto
- type OidcCredential
- type OidcCredentialOptions
- type ProviderClient
- type Response
- type TokenExpiredError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultRetryAfter ¶
RetryAfterDefault returns a random duration between 5 and 10 seconds.
Types ¶
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
func NewAuthBase ¶
func NewAuthBase(configValue *config.ProviderConfig) *Auth
func (*Auth) AuthenticateClientCertificate ¶
func (*Auth) AuthenticateClientSecret ¶
func (*Auth) AuthenticateOIDC ¶
func (*Auth) AuthenticateUsingCli ¶
type Client ¶
type Client struct { Config *config.ProviderConfig BaseAuth *Auth }
Client is a base client for specific API clients implmented in services.
func NewApiClientBase ¶
func NewApiClientBase(providerConfig *config.ProviderConfig, baseAuth *Auth) *Client
ApiHttpResponse is a wrapper around http.Response that provides additional helper methods.
func (*Client) DoWaitForLifecycleOperationStatus ¶
func (*Client) Execute ¶
func (client *Client) Execute(ctx context.Context, scopes []string, method, url string, headers http.Header, body any, acceptableStatusCodes []int, responseObj any) (*Response, error)
Execute executes an HTTP request with the given method, url, headers, and body.
Parameters:
- ctx: context.Context - Provides context for the request, allowing for timeout and cancellation control.
- scopes: []string - A list of scopes that the request should be associated with. If no scopes are provided, the method attempts to infer the scope from the URL.
- method: string - Specifies the HTTP method to be used for the request (e.g., "GET", "POST", "PATCH").
- url: string - The URL to which the request is sent. This includes the scheme, host, path, and query parameters. The URL must be absolute and properly formatted.
- headers: http.Header - A collection of HTTP headers to include in the request. Headers provide additional information about the request, such as content type, authorization tokens, and custom metadata.
- body: any - The body of the request, which can be of any type. This is typically used for methods like POST and PATCH, where data needs to be sent to the server.
- acceptableStatusCodes: []int - A list of HTTP status codes that are considered acceptable for the response. If the response status code is not in this list, the method treats it as an error.
- responseObj: any - An optional parameter where the response body can be unmarshaled into. This is useful for directly obtaining a structured representation of the response data.
Returns:
- *Response: The response from the HTTP request.
- error: An error if the request fails. Possible error types include:
- UrlFormatError: Returned if the URL is invalid or not absolute.
- UnexpectedHttpStatusCodeError: Returned if the response status code is not acceptable.
If no scopes are provided, the method attempts to infer the scope from the URL. The URL is validated to ensure it is absolute and properly formatted. The HTTP request is then prepared and executed. The response status code is checked against the list of acceptable status codes. If the status code is not acceptable, an error is returned. If a responseObj is provided, the response body is unmarshaled into this object.
func (*Client) GetConfig ¶
func (client *Client) GetConfig() *config.ProviderConfig
GetConfig returns the provider configuration.
type LifecycleDto ¶
type LifecycleDto struct { Id string `json:"id"` Links LifecycleLinksDto `json:"links"` State LifecycleStateDto `json:"state"` Type LifecycleStateDto `json:"type"` CreatedDateTime string `json:"createdDateTime"` LastActionDateTime string `json:"lastActionDateTime"` RequestedBy LifecycleRequestedByDto `json:"requestedBy"` Stages []LifecycleStageDto `json:"stages"` }
type LifecycleLinkDto ¶
type LifecycleLinkDto struct {
Path string `json:"path"`
}
type LifecycleLinksDto ¶
type LifecycleLinksDto struct { Self LifecycleLinkDto `json:"self"` Environment LifecycleLinkDto `json:"environment"` }
type LifecycleRequestedByDto ¶
type LifecycleStageDto ¶
type LifecycleStageDto struct { Id string `json:"id"` Name string `json:"name"` State LifecycleStateDto `json:"state"` FirstActionDateTime string `json:"firstActionDateTime"` LastActionDateTime string `json:"lastActionDateTime"` }
type LifecycleStateDto ¶
type LifecycleStateDto struct {
Id string `json:"id"`
}
type OidcCredential ¶
type OidcCredential struct {
// contains filtered or unexported fields
}
func NewOidcCredential ¶
func NewOidcCredential(options *OidcCredentialOptions) (*OidcCredential, error)
func (*OidcCredential) GetToken ¶
func (w *OidcCredential) GetToken(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error)
type OidcCredentialOptions ¶
type ProviderClient ¶
type ProviderClient struct { Config *config.ProviderConfig Api *Client }
ProviderClient is a wrapper around the API client that provides additional helper methods.
type Response ¶
func (*Response) MarshallTo ¶
type TokenExpiredError ¶
type TokenExpiredError struct {
Message string
}
func (*TokenExpiredError) Error ¶
func (e *TokenExpiredError) Error() string