Class ArnIndex

java.lang.Object
software.amazon.smithy.aws.traits.ArnIndex
All Implemented Interfaces:
software.amazon.smithy.model.knowledge.KnowledgeIndex

public final class ArnIndex extends Object implements software.amazon.smithy.model.knowledge.KnowledgeIndex
Resolves and indexes the ARN templates for each resource in a service.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ArnIndex(software.amazon.smithy.model.Model model)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    getEffectiveOperationArn(software.amazon.smithy.model.shapes.ToShapeId service, software.amazon.smithy.model.shapes.ToShapeId operation)
    Gets the effective ARN of an operation based on the identifier bindings of the operation bound to a resource contained within a service.
    getFullResourceArnTemplate(software.amazon.smithy.model.shapes.ToShapeId service, software.amazon.smithy.model.shapes.ToShapeId resource)
    Expands the relative ARN of a resource with the service name to form a full ARN template.
    getServiceArnNamespace(software.amazon.smithy.model.shapes.ToShapeId serviceId)
    Gets the ARN service namespace of a service shape.
    Map<software.amazon.smithy.model.shapes.ShapeId,ArnTrait>
    getServiceResourceArns(software.amazon.smithy.model.shapes.ToShapeId service)
    Gets all of the mappings of resources within a service to its arnTemplate trait.
    static ArnIndex
    of(software.amazon.smithy.model.Model model)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ArnIndex

      public ArnIndex(software.amazon.smithy.model.Model model)
  • Method Details

    • of

      public static ArnIndex of(software.amazon.smithy.model.Model model)
    • getServiceArnNamespace

      public String getServiceArnNamespace(software.amazon.smithy.model.shapes.ToShapeId serviceId)
      Gets the ARN service namespace of a service shape.
      Parameters:
      serviceId - Service shape to get ARN namespace of.
      Returns:
      Returns the resolved ARN service namespace, defaulting to the lowercase shape name if not known.
    • getServiceResourceArns

      public Map<software.amazon.smithy.model.shapes.ShapeId,ArnTrait> getServiceResourceArns(software.amazon.smithy.model.shapes.ToShapeId service)
      Gets all of the mappings of resources within a service to its arnTemplate trait.
      Parameters:
      service - Service to retrieve.
      Returns:
      Returns the mapping of resource ID to arnTemplate traits.
    • getEffectiveOperationArn

      public Optional<ArnTrait> getEffectiveOperationArn(software.amazon.smithy.model.shapes.ToShapeId service, software.amazon.smithy.model.shapes.ToShapeId operation)
      Gets the effective ARN of an operation based on the identifier bindings of the operation bound to a resource contained within a service.

      An operation bound to a resource using a collection binding has an effective ARN of the parent of the resource. An operation bound to a resource using an instance binding uses the ARN of the resource as its effective ARN.

      Parameters:
      service - Service the operation is bound within.
      operation - Operation shape for which to find the effective ARN.
      Returns:
      Returns the optionally found effective ARN.
    • getFullResourceArnTemplate

      public Optional<String> getFullResourceArnTemplate(software.amazon.smithy.model.shapes.ToShapeId service, software.amazon.smithy.model.shapes.ToShapeId resource)
      Expands the relative ARN of a resource with the service name to form a full ARN template.

      For relative ARNs, the returned template string is in the format of arn:{AWS::Partition}:service:{AWS::Region}:{AWS::AccountId}:resource where "service" is the resolved ARN service name of the service and "resource" is the resource part of the arnTemplate template. "{AWS::Region}" is added to the template if the arnTemplate "noRegion" value is not set to true. "{AWS::AccountId}" is added to the template if the arnTemplate "noAccount" value is not set to true.

      For example, if both "noAccount" and "noRegion" are set to true, the resolved ARN template might look like "arn:{AWS::Partition}:service:::resource".

      Absolute ARN templates are returned as-is.

      Parameters:
      service - Service shape ID.
      resource - Resource shape ID.
      Returns:
      Returns the optionally found ARN template for a resource.