This pull request refactors the authentication configuration in api_client.go and auth.go. It introduces the ProviderClient struct as a wrapper around the API client, providing additional helper methods. It also adds the GetConfig method to the ApiClient struct to retrieve the provider configuration. The TryGetScopeFromURL function now returns the authorization scope for the given API URL. The ExecuteForGivenScope method is added to execute an HTTP request with a specific scope, method, URL, headers, body, acceptable status codes, and response object. The Execute method is modified to use the TryGetScopeFromURL function and handle the response object. The RetryAfterDefault method now returns a random duration between 5 and 10 seconds. The SleepWithContext method is added to sleep for a given duration or until the context is canceled. Additionally, the providerError struct is renamed to ProviderError, and the NewProviderError and WrapIntoProviderError functions are modified to use the ProviderError struct.
This pull request refactors the authentication configuration in
api_client.go
andauth.go
. It introduces theProviderClient
struct as a wrapper around the API client, providing additional helper methods. It also adds theGetConfig
method to theApiClient
struct to retrieve the provider configuration. TheTryGetScopeFromURL
function now returns the authorization scope for the given API URL. TheExecuteForGivenScope
method is added to execute an HTTP request with a specific scope, method, URL, headers, body, acceptable status codes, and response object. TheExecute
method is modified to use theTryGetScopeFromURL
function and handle the response object. TheRetryAfterDefault
method now returns a random duration between 5 and 10 seconds. TheSleepWithContext
method is added to sleep for a given duration or until the context is canceled. Additionally, theproviderError
struct is renamed toProviderError
, and theNewProviderError
andWrapIntoProviderError
functions are modified to use theProviderError
struct.