Documentation
¶
Overview ¶
Package client provides a base client implementation for interacting with EdgeCast CDN APIs. Configuration and authentication types are also provided.
Index ¶
- type AuthorizationHeaderProvider
- type Client
- func (c *Client) BuildRequest(method, path string, body interface{}) (*retryablehttp.Request, error)
- func (c *Client) SendRequest(req *retryablehttp.Request, parsedResponse interface{}) (*http.Response, error)
- func (c *Client) SendRequestWithStringResponse(req *retryablehttp.Request) (*string, error)
- type ClientConfig
- type DefaultIDSClient
- type GetIDSTokenResponse
- type IDSAuthorizationHeaderProvider
- type IDSClient
- type IDSCredentials
- type IDSToken
- type LegacyAuthorizationHeaderProvider
- type LiteralResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthorizationHeaderProvider ¶
AuthorizationHeaderProvider defines structs that can provide Authorization headers
type Client ¶
type Client struct {
// Config holds the configuration values for this client
Config ClientConfig
// Internal HTTP client
HTTPClient *retryablehttp.Client
}
Client is the primary means for services to interact with the EdgeCast API
func NewClient ¶
func NewClient(config ClientConfig) *Client
Creates a new client pointing to EdgeCast APIs
func (*Client) BuildRequest ¶
func (c *Client) BuildRequest(method, path string, body interface{}) (*retryablehttp.Request, error)
BuildRequest creates a new Request for the Edgecast API, adding appropriate headers
func (*Client) SendRequest ¶
func (c *Client) SendRequest(req *retryablehttp.Request, parsedResponse interface{}) (*http.Response, error)
SendRequest sends an HTTP request and, if applicable, sets the response to parsedResponse
func (*Client) SendRequestWithStringResponse ¶
func (c *Client) SendRequestWithStringResponse(req *retryablehttp.Request) (*string, error)
SendRequest sends an HTTP request and, if applicable, sets the response to parsedResponse
type ClientConfig ¶
type ClientConfig struct {
// Generates Authorization Header values for HTTP requests
AuthHeaderProvider AuthorizationHeaderProvider
// APIURL contains the base URL for the target API
BaseAPIURL *url.URL
// The User Agent specifed for HTTP requests
UserAgent string
// Logger -
Logger edgecast.Logger
}
ClientConfig provides configuration for the base client
func NewAPIClientConfig ¶
func NewAPIClientConfig(credentials IDSCredentials) (*ClientConfig, error)
NewAPIClientConfig creates a new ClientConfig for targeting the EdgeCast API The EdgeCast API uses OAuth 2.0 credentials
func NewLegacyAPIClientConfig ¶
func NewLegacyAPIClientConfig(apiToken string) (*ClientConfig, error)
NewLegacyAPIClientConfig creates a new ClientConfig for targeting the legacy EdgeCast API The legacy APIs use an API Token
type DefaultIDSClient ¶
Calls the IDS token endpoint
func (DefaultIDSClient) GetIDSToken ¶
func (c DefaultIDSClient) GetIDSToken(credentials IDSCredentials) (*GetIDSTokenResponse, error)
Gets a new token from the IDS Token Endpoint
type GetIDSTokenResponse ¶
type GetIDSTokenResponse struct {
AccessToken string `json:"access_token"`
ExpiresIn float64 `json:"expires_in"`
TokenType string `json:"token_type"`
Scope string `json:"scope"`
}
GetIDSTokenResponse -
type IDSAuthorizationHeaderProvider ¶
type IDSAuthorizationHeaderProvider struct {
// The latest IDS token. May be expired.
CurrentToken *IDSToken
// Calls the IDS token endpoint for new tokens
IDSClient IDSClient
Credentials IDSCredentials
}
Generates IDS Authoriation Header values
func NewIDSAuthorizationHeaderProvider ¶
func NewIDSAuthorizationHeaderProvider(credentials IDSCredentials) (*IDSAuthorizationHeaderProvider, error)
Creates a new IDSAuthorizationHeaderProvider with the given credentials
func (*IDSAuthorizationHeaderProvider) GetAuthorizationHeader ¶
func (ip *IDSAuthorizationHeaderProvider) GetAuthorizationHeader() (string, error)
GetAuthorizationHeader creates an authorization value for the current token, refreshing it if it has expired. Used for EdgeCast APIs that use IDS OAuth 2.0 tokens.
type IDSClient ¶
type IDSClient interface {
GetIDSToken(credentials IDSCredentials) (*GetIDSTokenResponse, error)
}
Defines a way of getting an IDS Token
type IDSCredentials ¶
Holds a customer's IDS Credentials
type LegacyAuthorizationHeaderProvider ¶
type LegacyAuthorizationHeaderProvider struct {
APIToken string
}
LegacyAuthorizationHeaderProvider creates authorization header values for legacy EdgeCast API calls
func NewLegacyAuthorizationHeaderProvider ¶
func NewLegacyAuthorizationHeaderProvider(apiToken string) (*LegacyAuthorizationHeaderProvider, error)
NewLegacyAuthorizationHeaderProvider -
func (*LegacyAuthorizationHeaderProvider) GetAuthorizationHeader ¶
func (lp *LegacyAuthorizationHeaderProvider) GetAuthorizationHeader() (string, error)
GetAuthorizationHeader gets the authorization header value for legacy EdgeCast API calls
type LiteralResponse ¶
type LiteralResponse struct {
Value interface{}
}
LiteralResponse is used for unmarshaling response data that is in an unrecognized format