Documentation
¶
Index ¶
- func BuildEndpointURL(baseURL, path string, params, query map[string]string) (string, error)
- func ConfigDir() (string, error)
- func CredentialsPath() (string, error)
- func SaveCredential(path string, credential Credential) error
- func ServiceAccountJWT(account ServiceAccountFile, now time.Time) (string, error)
- func ValidateCredential(credential Credential) error
- type AGCError
- type Client
- type Credential
- type CredentialStore
- type InvokeRequest
- type InvokeResponse
- type PaginatedResponse
- type ServiceAccountFile
- type TokenResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildEndpointURL ¶
func CredentialsPath ¶
func SaveCredential ¶
func SaveCredential(path string, credential Credential) error
func ServiceAccountJWT ¶
func ServiceAccountJWT(account ServiceAccountFile, now time.Time) (string, error)
func ValidateCredential ¶
func ValidateCredential(credential Credential) error
Types ¶
type AGCError ¶
type AGCError struct {
StatusCode int `json:"statusCode"`
Code string `json:"code,omitempty"`
Message string `json:"message"`
RawBody json.RawMessage `json:"rawBody,omitempty"`
}
func ParseAGCError ¶
type Client ¶
func (Client) TokenEndpoint ¶
type Credential ¶
type Credential struct {
Name string `json:"name"`
Mode string `json:"mode"`
ServiceAccountFile string `json:"serviceAccountFile,omitempty"`
ClientID string `json:"clientId,omitempty"`
ClientKey string `json:"clientKey,omitempty"`
Active bool `json:"active,omitempty"`
CreatedAt time.Time `json:"createdAt"`
}
func ActiveCredential ¶
func ActiveCredential(store CredentialStore) (Credential, bool)
func CredentialByName ¶
func CredentialByName(store CredentialStore, name string) (Credential, bool)
type CredentialStore ¶
type CredentialStore struct {
Accounts []Credential `json:"accounts"`
}
func LoadCredentials ¶
func LoadCredentials(path string) (CredentialStore, error)
type InvokeRequest ¶
type InvokeRequest struct {
Endpoint domain.Endpoint `json:"endpoint"`
BaseURL string `json:"baseUrl"`
Params map[string]string `json:"params,omitempty"`
Query map[string]string `json:"query,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
Body []byte `json:"-"`
AccessToken string `json:"-"`
DryRun bool `json:"dryRun"`
}
type InvokeResponse ¶
type InvokeResponse struct {
Method string `json:"method"`
URL string `json:"url"`
StatusCode int `json:"statusCode,omitempty"`
ContentType string `json:"contentType,omitempty"`
Body json.RawMessage `json:"body,omitempty"`
RawBody []byte `json:"-"`
DryRun bool `json:"dryRun"`
}
func InvokeEndpoint ¶
func InvokeEndpoint(ctx context.Context, client *http.Client, req InvokeRequest) (InvokeResponse, error)
type PaginatedResponse ¶
type ServiceAccountFile ¶
type ServiceAccountFile struct {
ProjectID string `json:"project_id"`
KeyID string `json:"key_id"`
PrivateKey string `json:"private_key"`
SubAccount string `json:"sub_account"`
TokenURI string `json:"token_uri"`
}
func LoadServiceAccount ¶
func LoadServiceAccount(path string) (ServiceAccountFile, error)
type TokenResponse ¶
type TokenResponse struct {
AccessToken string `json:"access_token"`
TokenType string `json:"token_type,omitempty"`
ExpiresIn int `json:"expires_in,omitempty"`
}
func APIClientToken ¶
func AccessToken ¶
func AccessToken(ctx context.Context, client *http.Client, baseURL string, credential Credential) (TokenResponse, error)
Click to show internal directories.
Click to hide internal directories.