database

package
v0.0.0-...-519451a Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: OSL-3.0 Imports: 20 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 database provides Azure SQL Database Reserved Capacity client

Index

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

func (c *Client) GetExistingCommitments(ctx context.Context) ([]common.Commitment, error)

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) GetRegion

func (c *Client) GetRegion() string

GetRegion returns the region.

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

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

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

type SQLPricing struct {
	Currency         string
	HourlyRate       float64
	ReservationPrice float64
}

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).

Jump to

Keyboard shortcuts

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