Documentation
¶
Overview ¶
Package azure provides thin typed REST clients for the Azure services commons-db uses (Key Vault keys, Log Analytics queries), built on commons/http with SDK-free Azure AD bearer tokens.
Index ¶
Constants ¶
const ( // DefaultLogAnalyticsEndpoint is the public-cloud Log Analytics API root. DefaultLogAnalyticsEndpoint = "https://api.loganalytics.io/v1" // DefaultLogAnalyticsScope is the public-cloud Log Analytics token scope. DefaultLogAnalyticsScope = "https://api.loganalytics.io/.default" )
const (
// AlgRSAOAEP256 is the RSA-OAEP-256 key encryption algorithm.
AlgRSAOAEP256 = "RSA-OAEP-256"
)
Variables ¶
This section is empty.
Functions ¶
func IsNotFound ¶
IsNotFound reports whether err is an Azure API 404.
func KeyVaultScope ¶
KeyVaultScope returns the token scope for the vault at vaultURL: the host minus its vault-name label, so sovereign clouds (vault.usgovcloudapi.net, vault.azure.cn) get their own audience.
Types ¶
type APIError ¶
APIError is an error returned by an Azure REST API. Code and Message come from the {"error":{"code","message"}} envelope; when the body is not an envelope, Message holds the (truncated) raw body.
type ErrorDetail ¶
ErrorDetail is the Azure error envelope payload.
type KeyOperation ¶
KeyOperation names a key and the data an encrypt/decrypt call operates on. An empty Version selects the latest key version.
type KeyVaultClient ¶
type KeyVaultClient struct {
// contains filtered or unexported fields
}
KeyVaultClient performs Key Vault key cryptographic operations.
func NewKeyVaultClient ¶
func NewKeyVaultClient(opts KeyVaultOptions) (*KeyVaultClient, error)
NewKeyVaultClient builds a client for one vault.
func (*KeyVaultClient) Decrypt ¶
func (c *KeyVaultClient) Decrypt(ctx context.Context, op KeyOperation) ([]byte, error)
Decrypt decrypts op.Value with the key and returns the plaintext.
func (*KeyVaultClient) Encrypt ¶
func (c *KeyVaultClient) Encrypt(ctx context.Context, op KeyOperation) ([]byte, error)
Encrypt encrypts op.Value with the key and returns the ciphertext.
type KeyVaultOptions ¶
type KeyVaultOptions struct {
// VaultURL is the vault base URL, e.g. https://name.vault.azure.net/.
VaultURL string
Credential azuread.Credential
// Scope overrides the token scope, which is otherwise derived from the
// vault host's cloud suffix (see KeyVaultScope).
Scope string
// SkipTLSVerify disables server certificate verification.
SkipTLSVerify bool
}
KeyVaultOptions configures a KeyVaultClient.
type LogAnalyticsClient ¶
type LogAnalyticsClient struct {
// contains filtered or unexported fields
}
LogAnalyticsClient queries Log Analytics workspaces.
func NewLogAnalyticsClient ¶
func NewLogAnalyticsClient(opts LogAnalyticsOptions) (*LogAnalyticsClient, error)
NewLogAnalyticsClient builds a Log Analytics client.
func (*LogAnalyticsClient) Query ¶
func (c *LogAnalyticsClient) Query(ctx context.Context, req QueryRequest) (*QueryResult, error)
Query runs a KQL query against a workspace.
type LogAnalyticsOptions ¶
type LogAnalyticsOptions struct {
Credential azuread.Credential
// Endpoint is the API root including the version, default DefaultLogAnalyticsEndpoint.
Endpoint string
// Scope is the token scope, default DefaultLogAnalyticsScope.
Scope string
// SkipTLSVerify disables server certificate verification.
SkipTLSVerify bool
}
LogAnalyticsOptions configures a LogAnalyticsClient. Endpoint and Scope replace the Azure SDK's cloud configuration for sovereign clouds, e.g. Endpoint "https://api.loganalytics.us/v1" with Scope "https://api.loganalytics.us/.default". The token authority is configured on Credential (azuread.ClientSecret.Authority).
type QueryRequest ¶
QueryRequest is one workspace query. Timespan is an ISO8601 "start/end" interval and is omitted when empty.
type QueryResult ¶
type QueryResult struct {
Tables []Table `json:"tables"`
Error *ErrorDetail `json:"error,omitempty"`
}
QueryResult holds the tables returned by a query. Error is set when the service returned a partial failure alongside a 2xx response.