Documentation
¶
Overview ¶
Package database provides Azure SQL Database Reserved Capacity client
Index ¶
- func Details(sku string) *common.DatabaseDetails
- type AzureRetailPrice
- type CapabilitiesClient
- type Client
- func (c *Client) GetExistingCommitments(ctx context.Context) ([]common.Commitment, error)
- func (c *Client) GetOfferingDetails(ctx context.Context, rec common.Recommendation) (*common.OfferingDetails, error)
- func (c *Client) GetRecommendations(ctx context.Context, _ *common.RecommendationParams) ([]common.Recommendation, error)
- func (c *Client) GetRegion() string
- func (c *Client) GetServiceType() common.ServiceType
- func (c *Client) PurchaseCommitment(ctx context.Context, rec common.Recommendation, opts common.PurchaseOptions) (common.PurchaseResult, error)
- func (c *Client) ReservationUnitPrice(ctx context.Context, sku, region string, termYears int) (azrecs.ReservationPrice, error)
- func (c *Client) SetCapabilitiesClient(client CapabilitiesClient)
- func (c *Client) SetInventoryFactories(f *reservations.InventoryFactories)
- func (c *Client) SetManagedInstancesPager(pager SQLManagedInstancesPager)
- func (c *Client) SetRecommendationsPager(pager RecommendationsPager)
- func (c *Client) SetServersPager(pager SQLServersPager)
- type HTTPClient
- type RecommendationsPager
- type SQLManagedInstancesPager
- type SQLPricing
- type SQLServersPager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Details ¶
func Details(sku string) *common.DatabaseDetails
Details parses an Azure SQL SKU string into a *common.DatabaseDetails. The Azure Reservation Recommendations API returns SKU strings like "GeneralPurpose_Gen5_2" (edition, compute generation, vcore count) or "BusinessCritical_Gen5_4". The parser is permissive: unknown formats populate InstanceClass and leave the rest blank — converters must never return an error on unexpected SKU strings because the API can add new SKUs without breaking consumers.
Engine is always "sqlserver". EngineVersion, AZConfig, and Deployment are enriched by the lazy subscription-wide cached lookups in convertAzureSQLRecommendation; they are left empty here.
Types ¶
type AzureRetailPrice ¶
type AzureRetailPrice = pricing.Page[pricing.RetailPriceItem]
AzureRetailPrice is the response envelope for the Azure Retail Prices API.
type CapabilitiesClient ¶
type CapabilitiesClient interface {
ListByLocation(ctx context.Context, locationName string, options *armsql.CapabilitiesClientListByLocationOptions) (armsql.CapabilitiesClientListByLocationResponse, error)
}
CapabilitiesClient interface for SQL capabilities (enables mocking).
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client handles Azure SQL Database Reserved Capacity.
func NewClient ¶
func NewClient(cred azcore.TokenCredential, subscriptionID, region string) *Client
NewClient creates a new Azure Database client.
func NewClientWithHTTP ¶
func NewClientWithHTTP(cred azcore.TokenCredential, subscriptionID, region string, httpClient HTTPClient) *Client
NewClientWithHTTP creates a new Azure Database client with a custom HTTP client (for testing). When httpClient is nil, the SSRF-hardened httpclient.New() is used so the nil fallback also blocks IMDS connections. A non-nil httpClient is used as-is and bypasses that guard: metadata, NAT64/6to4 and unspecified addresses are dialable unless the caller's client blocks them itself.
func (*Client) GetExistingCommitments ¶
GetExistingCommitments retrieves the SQL Database reservations that apply to this subscription from the Reservations API, which carries the purchase date, quantity, location and lifecycle state the duplicate-purchase guard needs (issue #705). Any failure or incomplete live row is returned as an error rather than as an empty or partial inventory.
The dedupe key includes engine and deployment, and recommendations carry Engine "sqlserver" and the subscription's dominant AZConfig, so held reservations are stamped with the same values. The server walk is skipped when nothing is held.
func (*Client) GetOfferingDetails ¶
func (c *Client) GetOfferingDetails(ctx context.Context, rec common.Recommendation) (*common.OfferingDetails, error)
GetOfferingDetails retrieves SQL Database reservation offering details from Azure Retail Prices API.
func (*Client) GetRecommendations ¶
func (c *Client) GetRecommendations(ctx context.Context, _ *common.RecommendationParams) ([]common.Recommendation, error)
GetRecommendations gets SQL Database reservation recommendations from Azure Consumption API.
func (*Client) GetServiceType ¶
func (c *Client) GetServiceType() common.ServiceType
GetServiceType returns the service type.
func (*Client) PurchaseCommitment ¶
func (c *Client) PurchaseCommitment(ctx context.Context, rec common.Recommendation, opts common.PurchaseOptions) (common.PurchaseResult, error)
PurchaseCommitment purchases SQL Database reserved capacity using the two-step calculatePrice->purchase flow required by Azure's Reservations API (issue #677).
func (*Client) ReservationUnitPrice ¶
func (c *Client) ReservationUnitPrice(ctx context.Context, sku, region string, termYears int) (azrecs.ReservationPrice, error)
ReservationUnitPrice returns the Retail Prices reservation total and currency for one unit of sku in region over termYears.
func (*Client) SetCapabilitiesClient ¶
func (c *Client) SetCapabilitiesClient(client CapabilitiesClient)
SetCapabilitiesClient sets the capabilities client (for testing).
func (*Client) SetInventoryFactories ¶
func (c *Client) SetInventoryFactories(f *reservations.InventoryFactories)
SetInventoryFactories injects reservation-inventory factories (for testing).
func (*Client) SetManagedInstancesPager ¶
func (c *Client) SetManagedInstancesPager(pager SQLManagedInstancesPager)
SetManagedInstancesPager sets the SQL managed instances pager (for testing).
func (*Client) SetRecommendationsPager ¶
func (c *Client) SetRecommendationsPager(pager RecommendationsPager)
SetRecommendationsPager sets the recommendations pager (for testing).
func (*Client) SetServersPager ¶
func (c *Client) SetServersPager(pager SQLServersPager)
SetServersPager sets the SQL servers pager (for testing).
type HTTPClient ¶
HTTPClient interface for HTTP operations (enables mocking).
type RecommendationsPager ¶
type RecommendationsPager interface {
More() bool
NextPage(ctx context.Context) (armconsumption.ReservationRecommendationsClientListResponse, error)
}
RecommendationsPager interface for recommendations pager (enables mocking).
type SQLManagedInstancesPager ¶
type SQLManagedInstancesPager interface {
More() bool
NextPage(ctx context.Context) (armsql.ManagedInstancesClientListResponse, error)
}
SQLManagedInstancesPager interface for listing SQL managed instances (enables mocking).
type SQLPricing ¶
SQLPricing contains pricing information for SQL Database.
type SQLServersPager ¶
type SQLServersPager interface {
More() bool
NextPage(ctx context.Context) (armsql.ServersClientListResponse, error)
}
SQLServersPager interface for listing SQL servers (enables mocking).