Class EnvironmentRef

java.lang.Object
com.eqixiac.equinix.core.model.multicloud.EnvironmentRef

public class EnvironmentRef extends Object
A specification environment seen from the customer side: the pair of provider sites a connection joins, the environment id both providers agreed on, the connection sizes the environment supports and its visibility (environment.yaml#/Environment).

Beta: derived from the open specification at commit bbfc763 (see the package documentation).

The specification's example: AWS us-east-1 and GCP us-east4 joined by the environment id aws-gcp-us-east, addressed as providers/aws/environments/aws-gcp-us-east by one provider and providers/gcp/environments/aws-gcp-us-east by the other (docs/Protocols.md).

Fields
FieldSpecification fieldConstraint
environmentIdlast segment of name required, not blank, no /; trimmed; case is preserved
providerSitesproviderSites exactly two entries with different providers; stored in canonical order (by provider id), unmodifiable
supportedConnectionSizeMbpssupportedConnectionSizeMbps Mbps; null becomes BandwidthTier.none()
visibilityenvironmentVisibility null becomes EnvironmentVisibility.UNKNOWN

Order-insensitivity

The two sites are an unordered pair. The constructor sorts them by provider id, so two instances built with the sites in either order are equal, have the same hash code and the same toString(). connects(ProviderRef, String, ProviderRef, String) accepts its two endpoints in either order.

Omitted specification fields

apiUri, supportedFeatures, deferralTimeoutHours and deferConnectionProvisioning describe provider-to-provider coordination and are not modelled.

Construct with of(String, ProviderSite, ProviderSite) or the Lombok builder (EnvironmentRef.builder().environmentId(...).providerSite(...).providerSite(...) .supportedConnectionSizeMbps(...).visibility(...).build()).

Author:
ianjones
  • Method Details

    • of

      public static EnvironmentRef of(String environmentId, ProviderSite oneSide, ProviderSite otherSide)
      Creates an environment reference with no published sizes and UNKNOWN visibility. The two sites are an unordered pair; swapping them produces an equal instance.
      Parameters:
      environmentId - the agreed environment id
      oneSide - one provider site
      otherSide - the other provider site; its provider must differ from oneSide's
      Returns:
      the environment reference
      Throws:
      NullPointerException - if any argument is null
      IllegalArgumentException - if environmentId is blank or contains /, or both sites name the same provider
    • involves

      public boolean involves(ProviderRef provider)
      Parameters:
      provider - a provider
      Returns:
      true when provider is one of the two providers of this environment
    • siteOf

      public Optional<String> siteOf(ProviderRef provider)
      Parameters:
      provider - a provider
      Returns:
      that provider's site name in this environment, or empty when provider is null or is not one of the two providers
    • otherSide

      public Optional<ProviderRef> otherSide(ProviderRef provider)
      Parameters:
      provider - one of the two providers of this environment
      Returns:
      the other provider, or empty when provider is null or is not one of the two providers
    • connects

      public boolean connects(ProviderRef a, String aSite, ProviderRef z, String zSite)
      Tests whether this environment joins the two given provider sites. The endpoints may be given in either order. Site names are compared after trimming and without regard to case (see ProviderSite.matches(ProviderRef, String)).
      Parameters:
      a - one provider
      aSite - the site name at a
      z - the other provider
      zSite - the site name at z
      Returns:
      true when one site of this environment matches (a, aSite) and the other matches (z, zSite); false when any argument is null
    • resourceName

      public String resourceName(ProviderRef addressedAs)
      The specification resource name of this environment as addressed under one provider's prefix: providers/{provider}/environments/{environmentId}.
      Parameters:
      addressedAs - the provider whose id forms the providers/ prefix; must be one of the two providers of this environment
      Returns:
      the resource name
      Throws:
      NullPointerException - if addressedAs is null
      IllegalArgumentException - if addressedAs is not one of the two providers
    • matchesUri

      public boolean matchesUri(String environmentUri)
      Tests whether an environment URI, such as an activation key's destinationEnvironmentUri, names this environment. The URI matches when its environment id (see environmentIdOf(String)) equals this environmentId exactly. The providers/{provider} segment is not compared: the specification addresses one environment under either provider's prefix and does not state which prefix an activation key carries.
      Parameters:
      environmentUri - a resource name or URL containing environments/{id}
      Returns:
      true when the URI's environment id equals this environment's id; false when environmentUri is null or carries no environment id
    • environmentIdOf

      public static Optional<String> environmentIdOf(String environmentUri)
      Extracts the environment id from a resource name or URL: the path segment that follows the last environments segment. Query strings and fragments are ignored.
      Examples
      InputResult
      providers/aws/environments/aws-gcp-us-eastaws-gcp-us-east
      /providers/gcp/environments/aws-gcp-us-east/interconnects/i1 aws-gcp-us-east
      https://host/v1/providers/aws/environments/e1?x=1e1
      providers/aws, environments/, nullempty
      Parameters:
      environmentUri - a resource name or URL; may be null
      Returns:
      the environment id, or empty when none is present