Documentation ¶
Index ¶
- type AkamaiEnvironmentVar
- type Config
- func (c *Config) WithAccountSwitchKey(ask string) *Config
- func (c *Config) WithCredentials(creds *Credentials) *Config
- func (c *Config) WithLocalTesting(localTesting bool) *Config
- func (c *Config) WithLogVerbosity(logVerbosity string) *Config
- func (c *Config) WithRequestDebug(requestDebug bool) *Config
- func (c *Config) WithScheme(scheme string) *Config
- func (c *Config) WithTestingURL(testingURL string) *Config
- func (c *Config) WithUserAgent(ua string) *Config
- type Credentials
- type CredentialsBuilder
- func (ea *CredentialsBuilder) AutoLoad(section string) *Credentials
- func (ea *CredentialsBuilder) FromEnv() (*Credentials, error)
- func (ea *CredentialsBuilder) FromFile(fileName string) *CredentialsBuilder
- func (ea *CredentialsBuilder) FromJSON(json string) (*Credentials, error)
- func (ea *CredentialsBuilder) Section(section string) (*Credentials, error)
- type ErrorCredentials
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AkamaiEnvironmentVar ¶
type AkamaiEnvironmentVar string
AkamaiEnvironmentVar represents Akamai's env variables used
const ( EnvVarEdgercPath AkamaiEnvironmentVar = "AKAMAI_EDGERC_CONFIG" EnvVarEdgercSection AkamaiEnvironmentVar = "AKAMAI_EDGERC_SECTION" EnvVarDebugLevelSection AkamaiEnvironmentVar = "AKAMAI_EDGERC_DEBUGLEVEL" )
type Config ¶
type Config struct { // Defines account switch key used to manage sub-accounts with partner API keys AccountSwitchKey string // Credentials holds the current credentials configuration Credentials *Credentials // LocalTesting determines if the host we would be using is local - so we can run tests LocalTesting bool // Defines log level output i.e. debug/error/warning/info LogVerbosity string // RequestDebug determines if we should print out debug info for http request/responses we make RequestDebug bool // Scheme used ( http or https ) Scheme string // TestingURL sets our desired url for mocked server TestingURL string // Used for adding the User Agent header for the requests we make towards APIs UserAgent string }
Config represents options that are passed during client initialization
func NewConfig ¶
func NewConfig() *Config
NewConfig returns a new Config pointer that can be chained with builder methods to set multiple configuration values inline without using pointers.
// Create config with account switch key defined which can be used by the // service clients. cfg := edgegrid.NewConfig().WithAccountSwitchKey("MS-123BV")
func (*Config) WithAccountSwitchKey ¶
WithAccountSwitchKey sets account switch key used across calls a Config pointer.
func (*Config) WithCredentials ¶
func (c *Config) WithCredentials(creds *Credentials) *Config
WithCredentials sets a config Credentials value returning a Config pointer for chaining.
func (*Config) WithLocalTesting ¶
WithLocalTesting sets a config value to determine if local testing is being used and returns a Config pointer.
func (*Config) WithLogVerbosity ¶
WithLogVerbosity sets a config log verbosity and returns a Config pointer.
func (*Config) WithRequestDebug ¶
WithRequestDebug toggles debug of http requests/repsonse output
func (*Config) WithScheme ¶
WithScheme sets a config value for http calls scheme and returns a Config pointer.
func (*Config) WithTestingURL ¶
WithTestingURL sets a config value for test server URL and returns a Config pointer.
func (*Config) WithUserAgent ¶
WithUserAgent sets a config value for user agent and returns a Config pointer.
type Credentials ¶
type Credentials struct { //API based credentials Host string `ini:"host" json:"host" valid:"required~Host is empty/blank"` ClientToken string `ini:"client_token" json:"client_token" valid:"required~ClientToken is blank/empty"` ClientSecret string `ini:"client_secret" json:"client_secret" valid:"required~ClientSecret name is blank/empty"` AccessToken string `ini:"access_token" json:"access_token" valid:"required~AccessToken name is blank/empty"` //Netstorage based credentials HostName string `ini:"hostname"` Key string `ini:"key"` KeyName string `ini:"keyname"` CPCode int `ini:"cpcode"` }
A Credentials provides values and string type of credentials being used. Type can be of `netstorage` or `api`
type CredentialsBuilder ¶
type CredentialsBuilder struct { *Credentials // contains filtered or unexported fields }
CredentialsBuilder provides method to build credentials using methods chaining for easy retrieval.
func NewCredentials ¶
func NewCredentials() *CredentialsBuilder
NewCredentials is used to create new object on which we can chain our methods
Example for environment variables retrieval creds, err := credentials.NewCredentials().FromEnv()
if err != nil { fmt.Println(err) }
func (*CredentialsBuilder) AutoLoad ¶
func (ea *CredentialsBuilder) AutoLoad(section string) *Credentials
AutoLoad Tries to load credentials automatically from a environment variables or from section file.
func (*CredentialsBuilder) FromEnv ¶
func (ea *CredentialsBuilder) FromEnv() (*Credentials, error)
FromEnv Retrieves credentials from env variables which are prefixed with 'AKAMAI_' In order to sucesfully build credentials file we need the following variables:
AKAMAI_HOST AKAMAI_CLIENT_TOKEN AKAMAI_CLIENT_SECRET AKAMAI_ACCESS_TOKEN
Example of using the environment variable credentials.
credValue, err := credentials.NewEnvCredentials().FromEnv() if err != nil { // handle error }
func (*CredentialsBuilder) FromFile ¶
func (ea *CredentialsBuilder) FromFile(fileName string) *CredentialsBuilder
FromFile Retrieves credentials from the file ( and section ) specified
creds, err := credentials.NewCredentials().FromFile("/Users/username/.edgerc").Section("abc") if err != nil { fmt.Println(err) }
func (*CredentialsBuilder) FromJSON ¶
func (ea *CredentialsBuilder) FromJSON(json string) (*Credentials, error)
FromJSON Retrieves credentials from a given JSON string. Example use: creds, err := credentials.NewCredentials().FromJSON(`{ "client_secret": "x", "host": "y", "access_token": "z", "client_token": "b" }`)
if err != nil { fmt.Println(err) }
func (*CredentialsBuilder) Section ¶
func (ea *CredentialsBuilder) Section(section string) (*Credentials, error)
Section Should be used in conjuction with FromFile() and defines which section to read credentials from.
type ErrorCredentials ¶
type ErrorCredentials struct { ErrorMessage string `json:"error_message"` ErrorType string `json:"error_type"` }
ErrorCredentials represents an error caused during credentials retrieval
func (ErrorCredentials) Error ¶
func (e ErrorCredentials) Error() string
ErrorCredentials implements the error interface.