azure

package
v0.1.97 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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"
)
View Source
const (
	// AlgRSAOAEP256 is the RSA-OAEP-256 key encryption algorithm.
	AlgRSAOAEP256 = "RSA-OAEP-256"
)

Variables

This section is empty.

Functions

func IsNotFound

func IsNotFound(err error) bool

IsNotFound reports whether err is an Azure API 404.

func KeyVaultScope

func KeyVaultScope(vaultURL string) (string, error)

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

type APIError struct {
	StatusCode int
	Code       string
	Message    string
}

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.

func (*APIError) Error

func (e *APIError) Error() string

type Column

type Column struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

Column is a result table column.

type ErrorDetail

type ErrorDetail struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

ErrorDetail is the Azure error envelope payload.

type KeyOperation

type KeyOperation struct {
	Name      string
	Version   string
	Algorithm string
	Value     []byte
}

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

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

type QueryRequest struct {
	WorkspaceID string
	Query       string
	Timespan    string
}

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.

type Table

type Table struct {
	Name    string   `json:"name"`
	Columns []Column `json:"columns"`
	Rows    [][]any  `json:"rows"`
}

Table is one result table. Row values are JSON-decoded (numbers are float64, nulls are nil).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL