Documentation ¶
Overview ¶
Most of the code is lifted from https://github.com/googleapis/google-api-go-client/blob/main/internal/settings.go
For details and copyright etc. see above url.
Most of the code is lifted from https://github.com/googleapis/google-api-go-client/blob/main/internal/settings.go
For details and copyright etc. see above url.
Index ¶
Constants ¶
const ( ProjectID = "PROJECT_ID" ClientID = "CLIENT_ID" ClientSecret = "CLIENT_SECRET" AccessToken = "ACCESS_TOKEN" StateInit State = iota - 2 // waiting to swap tokens StateInvalid // a config in this state should not be used StateUndefined // logged out StateAuthorized // logged in )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Credentials ¶
type Credentials struct { ProjectID string `json:"project_id,omitempty"` ClientID string `json:"client_id,omitempty"` ClientSecret string `json:"client_secret,omitempty"` Token string `json:"token,omitempty"` Status State `json:"status,omitempty"` Expires int64 `json:"expires,omitempty"` // 0 = never, > 0 = unix timestamp, < 0 = invalid }
func CredentialsFromEnv ¶
func CredentialsFromEnv() *Credentials
func (*Credentials) Clone ¶
func (c *Credentials) Clone() *Credentials
Clone returns a deep copy of the credentials
func (*Credentials) Expired ¶
func (c *Credentials) Expired() bool
Expired only verifies just that, does not check all other attributes
func (*Credentials) HashedKey ¶
func (c *Credentials) HashedKey() string
func (*Credentials) IsValid ¶
func (c *Credentials) IsValid() bool
IsValid test if Crendentials is valid
func (*Credentials) Key ¶
func (c *Credentials) Key() string
type DialSettings ¶
type DialSettings struct { Endpoint string `json:"endpoint,omitempty"` Credentials *Credentials `json:"credentials,omitempty"` Scopes []string `json:"scopes,omitempty"` DefaultScopes []string `json:"default_scopes,omitempty"` UserAgent string `json:"user_agent,omitempty"` Options map[string]string `json:"options,omitempty"` // holds all other values ... }
DialSettings holds information needed to establish a connection with a backend API service or to simply configure a service/CLI.
func (*DialSettings) Clone ¶
func (ds *DialSettings) Clone() DialSettings
func (*DialSettings) GetOption ¶
func (ds *DialSettings) GetOption(opt string) string
GetOption returns the custom option opt if it exists or an empty string otherwise
func (*DialSettings) GetScopes ¶
func (ds *DialSettings) GetScopes() []string
GetScopes returns the user-provided scopes, if set, or else falls back to the default scopes.
func (*DialSettings) HasOption ¶
func (ds *DialSettings) HasOption(opt string) bool
HasOption returns true if ds has a custom option opt.
func (*DialSettings) SetOption ¶
func (ds *DialSettings) SetOption(opt, o string)
SetOptions registers a custom option o with key opt.