Class EnvironmentRef
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).
| Field | Specification field | Constraint |
|---|---|---|
environmentId | last segment of name |
required, not blank, no /; trimmed; case is preserved |
providerSites | providerSites |
exactly two entries with different providers; stored in canonical order (by provider id), unmodifiable |
supportedConnectionSizeMbps | supportedConnectionSizeMbps |
Mbps; null becomes BandwidthTier.none() |
visibility | environmentVisibility |
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 Summary
Modifier and TypeMethodDescriptionbooleanconnects(ProviderRef a, String aSite, ProviderRef z, String zSite) Tests whether this environment joins the two given provider sites.environmentIdOf(String environmentUri) Extracts the environment id from a resource name or URL: the path segment that follows the lastenvironmentssegment.booleaninvolves(ProviderRef provider) booleanmatchesUri(String environmentUri) Tests whether an environment URI, such as an activation key'sdestinationEnvironmentUri, names this environment.static EnvironmentRefof(String environmentId, ProviderSite oneSide, ProviderSite otherSide) Creates an environment reference with no published sizes andUNKNOWNvisibility.otherSide(ProviderRef provider) resourceName(ProviderRef addressedAs) The specification resource name of this environment as addressed under one provider's prefix:providers/{provider}/environments/{environmentId}.siteOf(ProviderRef provider)
-
Method Details
-
of
Creates an environment reference with no published sizes andUNKNOWNvisibility. The two sites are an unordered pair; swapping them produces an equal instance.- Parameters:
environmentId- the agreed environment idoneSide- one provider siteotherSide- the other provider site; its provider must differ fromoneSide's- Returns:
- the environment reference
- Throws:
NullPointerException- if any argument is nullIllegalArgumentException- ifenvironmentIdis blank or contains/, or both sites name the same provider
-
involves
- Parameters:
provider- a provider- Returns:
truewhenprovideris one of the two providers of this environment
-
siteOf
- Parameters:
provider- a provider- Returns:
- that provider's site name in this environment, or empty when
provideris null or is not one of the two providers
-
otherSide
- Parameters:
provider- one of the two providers of this environment- Returns:
- the other provider, or empty when
provideris null or is not one of the two providers
-
connects
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 (seeProviderSite.matches(ProviderRef, String)).- Parameters:
a- one provideraSite- the site name ataz- the other providerzSite- the site name atz- Returns:
truewhen one site of this environment matches(a, aSite)and the other matches(z, zSite);falsewhen any argument is null
-
resourceName
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 theproviders/prefix; must be one of the two providers of this environment- Returns:
- the resource name
- Throws:
NullPointerException- ifaddressedAsis nullIllegalArgumentException- ifaddressedAsis not one of the two providers
-
matchesUri
Tests whether an environment URI, such as an activation key'sdestinationEnvironmentUri, names this environment. The URI matches when its environment id (seeenvironmentIdOf(String)) equals thisenvironmentIdexactly. Theproviders/{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 containingenvironments/{id}- Returns:
truewhen the URI's environment id equals this environment's id;falsewhenenvironmentUriis null or carries no environment id
-
environmentIdOf
Extracts the environment id from a resource name or URL: the path segment that follows the lastenvironmentssegment. Query strings and fragments are ignored.Examples Input Result providers/aws/environments/aws-gcp-us-eastaws-gcp-us-east/providers/gcp/environments/aws-gcp-us-east/interconnects/i1aws-gcp-us-easthttps://host/v1/providers/aws/environments/e1?x=1e1providers/aws,environments/,nullempty - Parameters:
environmentUri- a resource name or URL; may be null- Returns:
- the environment id, or empty when none is present
-