Record Class EstateScope

java.lang.Object
java.lang.Record
com.eqixiac.equinix.design.estate.EstateScope
Record Components:
projectIds - Fabric project ids; empty for no project criterion
accountNumbers - account numbers as text; empty for no account criterion
resourceIds - explicit resource ids (ports, connections, routers, networks, tokens, devices) that are in scope whatever their project or account
entireAccount - true only when the caller explicitly asked for an unscoped run
maxResourcesPerType - the most resources of one type the collector reads before it stops and records the type as truncated

public record EstateScope(Set<String> projectIds, Set<String> accountNumbers, Set<String> resourceIds, boolean entireAccount, int maxResourcesPerType) extends Record
Which part of an Equinix estate an analysis reads.

An account can see far more than one customer's resources (the test account behind this SDK's live checks sees hundreds of routers and connections and dozens of projects owned by other people), so the analyser never reads "everything" by accident. A scope names project ids, account numbers, explicit resource ids, or a combination; an unscoped run must be requested with entireAccount(int), which still caps how many resources of each type are read.

Matching rules (admits(String, String, String)): a resource is in scope when it matches every non-empty project/account criterion, or when its id is listed explicitly.

  • Field Details

    • DEFAULT_MAX_RESOURCES_PER_TYPE

      public static final int DEFAULT_MAX_RESOURCES_PER_TYPE
      The default per-type ceiling: large enough for one customer's estate, small enough to stay polite.
      See Also:
  • Constructor Details

    • EstateScope

      public EstateScope(Set<String> projectIds, Set<String> accountNumbers, Set<String> resourceIds, boolean entireAccount, int maxResourcesPerType)
      Normalises the sets (sorted, immutable, blanks dropped) and validates the ceiling.
  • Method Details

    • projects

      public static EstateScope projects(String... projectIds)
      A scope of one or more Fabric projects.
      Parameters:
      projectIds - the project ids
      Returns:
      the scope
    • accounts

      public static EstateScope accounts(String... accountNumbers)
      A scope of one or more billing accounts. Fabric searches cannot filter every resource type by account, so an account scope reads up to maxResourcesPerType() of each type and keeps the matching ones; a larger estate is reported as truncated.
      Parameters:
      accountNumbers - the account numbers
      Returns:
      the scope
    • resources

      public static EstateScope resources(Collection<String> resourceIds)
      A scope of explicitly named resources.
      Parameters:
      resourceIds - the resource ids
      Returns:
      the scope
    • entireAccount

      public static EstateScope entireAccount(int maxResourcesPerType)
      An explicitly requested unscoped run over everything the credentials can see, capped at maxResourcesPerType resources of each type.
      Parameters:
      maxResourcesPerType - the per-type ceiling
      Returns:
      the scope
    • plusResources

      public EstateScope plusResources(String... ids)
      Returns a copy with additional explicit resource ids.
      Parameters:
      ids - the ids to add
      Returns:
      the new scope
    • withMaxResourcesPerType

      public EstateScope withMaxResourcesPerType(int max)
      Returns a copy with a different per-type ceiling.
      Parameters:
      max - the ceiling
      Returns:
      the new scope
    • isUnscoped

      public boolean isUnscoped()
      Whether the scope names no project, account or resource.
      Returns:
      true for an unscoped run
    • admits

      public boolean admits(String projectId, String accountNumber, String resourceId)
      Whether a resource is in scope.
      Parameters:
      projectId - the resource's project id, or null when the API does not report one
      accountNumber - the resource's account number, or null
      resourceId - the resource id
      Returns:
      true when the resource belongs to the scope
    • describe

      public String describe()
      A one-line description for reports.
      Returns:
      the description
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • projectIds

      public Set<String> projectIds()
      Returns the value of the projectIds record component.
      Returns:
      the value of the projectIds record component
    • accountNumbers

      public Set<String> accountNumbers()
      Returns the value of the accountNumbers record component.
      Returns:
      the value of the accountNumbers record component
    • resourceIds

      public Set<String> resourceIds()
      Returns the value of the resourceIds record component.
      Returns:
      the value of the resourceIds record component
    • entireAccount

      public boolean entireAccount()
      Returns the value of the entireAccount record component.
      Returns:
      the value of the entireAccount record component
    • maxResourcesPerType

      public int maxResourcesPerType()
      Returns the value of the maxResourcesPerType record component.
      Returns:
      the value of the maxResourcesPerType record component