Class GcpBillingCatalogRateCard

java.lang.Object
com.eqixiac.equinix.design.value.ratecard.provider.GcpBillingCatalogRateCard
All Implemented Interfaces:
RateCard

public final class GcpBillingCatalogRateCard extends Object implements RateCard
A RateCard that sources Google Cloud data-egress rates from the Cloud Billing Catalog API (https://cloudbilling.googleapis.com/v1/services/{service}/skus). Unlike the Azure and AWS adapters this API requires an API key, supplied at construction.

It lists the SKUs of the Compute Engine service and selects the network-egress ones: EgressPath.INTERNET maps to "Network Internet Egress" SKUs and EgressPath.PRIVATE to "Interconnect"/"Network Inter-Region" egress SKUs. The per-GiB figure is the first paid pricing tier (the free tier is skipped), computed from unitPrice.units + nanos. Every rate it returns is tagged PriceSource.PROVIDER_API.

Internet-egress selection is deterministic: many egress SKUs contain the word "egress", so a match must carry the "internet" marker (not merely "not-interconnect"), and when several qualify the adapter prefers the representative base rate - the standard, worldwide meter over the pricier Premium-Tier and destination-qualified (China/Australia) variants - rather than whichever happened to appear first in the catalogue.

GCP meters egress per gibibyte (GiBy), but the savings engine multiplies the rate by a decimal-gigabyte volume (1 TB = 1000 GB). To keep the two consistent the adapter converts $/GiB → $/GB by dividing by 1.073741824 (1 GiB = 1.073741824 GB), yielding a slightly lower per-GB number; the returned note records the original per-GiB figure.

This is an opt-in, pluggable source intended for a RateCard.layered(RateCard...) chain. It is fault-tolerant - a missing key, network error, or unrecognised response yields no rate rather than an exception. The SKU catalogue is fetched once (following pagination) on first success and cached for the adapter's lifetime; a failed fetch - including a failure on any page of the pagination, which would otherwise leave a partial catalogue and a wrong "cheapest SKU" - is never memoized, so the next lookup retries.

  • Field Details

    • DEFAULT_ENDPOINT

      public static final String DEFAULT_ENDPOINT
      The public Cloud Billing Catalog endpoint root; the default for create(String). Override via create(String, String) for a proxy or testing.
      See Also:
    • COMPUTE_ENGINE_SERVICE

      public static final String COMPUTE_ENGINE_SERVICE
      The Cloud Billing Catalog service id of Compute Engine - the service that owns GCP's network-egress SKUs, and therefore the one whose SKU list this adapter fetches.
      See Also:
  • Method Details

    • create

      public static GcpBillingCatalogRateCard create(String apiKey)
      Creates an adapter against the public Cloud Billing Catalog endpoint (DEFAULT_ENDPOINT). With a null/empty key every lookup returns empty without making a call, so the adapter can be composed unconditionally into a layered chain and simply contributes nothing when unconfigured.
      Parameters:
      apiKey - a Google API key authorised for the Cloud Billing Catalog API
    • create

      public static GcpBillingCatalogRateCard create(String apiKey, String endpoint)
      Creates an adapter against a custom endpoint root - for a proxy or testing.
      Parameters:
      apiKey - a Google API key authorised for the Cloud Billing Catalog API
      endpoint - the endpoint root (e.g. https://cloudbilling.googleapis.com)
    • connection

      public Optional<PriceQuote> connection(ConnectionType type, int bandwidthMbps, MetroCode metro, Term term)
      Description copied from interface: RateCard
      Resolves the price of a single Fabric connection / virtual connection.

      Implementation contract. The matching strategy is implementation-specific, and a card whose data lacks an axis (metro, term, type) still returns its best figure - or empty - rather than failing; callers must not assume every card is sensitive to every parameter. Of the bundled cards: CustomRateCard resolves the most specific declared entry (exact metro+term down to metro/term-agnostic, then a declared default); EquinixRateCard matches bandwidth and type against the live catalogue, honours a requested metro strictly (a wrong-metro row is never returned), and prefers a term-matched row - a different-term row is only ever returned with a note naming the substitution; ReferenceRateCard matches on bandwidth alone (smallest tabulated tier at or above the request, linearly extrapolated with an EXTRAPOLATED note above the top tier) and ignores type, metro, and term entirely.

      Specified by:
      connection in interface RateCard
      Parameters:
      type - the connection type (e.g. EVPL_VC); may be null for any type
      bandwidthMbps - the provisioned bandwidth in Mbps
      metro - the metro the connection originates in (may be null if metro-agnostic)
      term - the commitment term (may be null if term-agnostic)
      Returns:
      the resolved quote, or Optional.empty() if this card cannot price the connection
    • cloudRouter

      public Optional<PriceQuote> cloudRouter(String packageCode, MetroCode metro, Term term)
      Description copied from interface: RateCard
      Resolves the price of a single Fabric Cloud Router instance.

      Implementation contract. As with RateCard.connection(ConnectionType, int, MetroCode, Term), matching is implementation-specific and cards without a metro/term axis return their best figure regardless. Of the bundled cards: CustomRateCard resolves the most specific declared (packageCode, metro, term) entry; EquinixRateCard matches the package code and metro structurally against the row's own descriptor (exact package equality, the row's own metro code) and prefers a term-matched row, labelling any term substitution; ReferenceRateCard ignores metro and term, and substitutes its STANDARD figure for an unlisted package with a note naming the substitution.

      Specified by:
      cloudRouter in interface RateCard
      Parameters:
      packageCode - the router package / tier code (e.g. "STANDARD"); may be null for any
      metro - the metro the router is deployed in (may be null if metro-agnostic)
      term - the commitment term (may be null if term-agnostic)
      Returns:
      the resolved quote, or Optional.empty() if this card cannot price the router
    • egress

      public Optional<EgressRate> egress(CloudProviderType provider, String region, EgressPath path, Term term)
      Description copied from interface: RateCard
      Resolves the per-GB data-egress rate for a cloud provider over a given path.

      Equinix does not sell cloud egress, so EquinixRateCard returns Optional.empty() here (the default); egress rates come from a CustomRateCard (your figures), a ReferenceRateCard (bundled indicative figures), or a provider-pricing-API card. The default returns empty so cards that do not model egress need not override it. Cards whose data has no region or term axis ignore those parameters - the custom and reference cards match on provider + path alone; only the provider-API adapters are region-sensitive.

      Specified by:
      egress in interface RateCard
      Parameters:
      provider - the cloud provider the data is leaving
      region - the provider region (may be null for a provider-wide rate)
      path - internet vs. private interconnect
      term - the commitment term (may be null; ignored by term-agnostic cards)
      Returns:
      the resolved egress rate, or Optional.empty() if this card cannot price it
    • source

      public PriceSource source()
      Description copied from interface: RateCard
      The dominant provenance of prices this card produces. Aggregating cards report PriceSource.COMPOSITE.
      Specified by:
      source in interface RateCard
      Returns:
      the price source