Class OperationIndex

java.lang.Object
software.amazon.smithy.model.knowledge.OperationIndex
All Implemented Interfaces:
KnowledgeIndex

public final class OperationIndex extends Object implements KnowledgeIndex
Index of operation IDs to their resolved input, output, and error structures.

This index performs no validation that the input, output, and errors actually reference valid structures. Such operation inputs, outputs, and errors may be discarded as if they do not exist.

  • Constructor Details

    • OperationIndex

      public OperationIndex(Model model)
  • Method Details

    • of

      public static OperationIndex of(Model model)
    • getInput

      public Optional<StructureShape> getInput(ToShapeId operation)
      Gets the optional input structure of an operation, and returns an empty optional if the input targets smithy.api#Unit.
      Parameters:
      operation - Operation to get the input structure of.
      Returns:
      Returns the optional operation input structure.
    • getInputShape

      public Optional<StructureShape> getInputShape(ToShapeId operation)
      Gets the optional input structure of an operation.

      Operations in the model always have input. This operation will only return an empty optional if the given operation shape cannot be found in the model or if it is not an operation shape.

      Parameters:
      operation - Operation to get the input structure of.
      Returns:
      Returns the optional operation input structure.
    • expectInputShape

      public StructureShape expectInputShape(ToShapeId operation)
      Gets the input shape of an operation, and returns Smithy's Unit type trait if the operation has no meaningful input.

      In general, this method should be used instead of getInputShape(ToShapeId) when getting the input of operations that are known to exist.

      Parameters:
      operation - Operation to get the input of.
      Returns:
      Returns the input shape of the operation.
      Throws:
      ExpectationNotMetException - if the operation shape cannot be found.
    • getInputMembers

      public Map<String,MemberShape> getInputMembers(ToShapeId operation)
      Gets the input members of an operation as a map of member names to MemberShape.

      The return map is ordered using the same order defined in the model. If the operation has no input, an empty map is returned.

      Parameters:
      operation - Operation to get the input members of.
      Returns:
      Returns the map of members, or an empty map.
    • isInputStructure

      public boolean isInputStructure(ToShapeId structureId)
      Returns true if the given structure is used as input by any operation in the model or is marked with the input trait.
      Parameters:
      structureId - Structure to check.
      Returns:
      Returns true if the structure is used as input.
    • getInputBindings

      public Set<OperationShape> getInputBindings(ToShapeId input)
      Gets all the operations that bind the given shape as input.
      Parameters:
      input - The structure that may be used as input.
      Returns:
      Returns a set of operations that bind the given input shape.
    • getOutput

      public Optional<StructureShape> getOutput(ToShapeId operation)
      Gets the optional output structure of an operation, and returns an empty optional if the output targets smithy.api#Unit.
      Parameters:
      operation - Operation to get the output structure of.
      Returns:
      Returns the optional operation output structure.
    • getOutputShape

      public Optional<StructureShape> getOutputShape(ToShapeId operation)
      Gets the optional output structure of an operation.

      Operations in the model always have output. This operation will only return an empty optional if the given operation shape cannot be found in the model or if it is not an operation shape.

      Parameters:
      operation - Operation to get the output structure of.
      Returns:
      Returns the optional operation output structure.
    • expectOutputShape

      public StructureShape expectOutputShape(ToShapeId operation)
      Gets the output shape of an operation, and returns Smithy's unit type trait if the operation has no meaningful output.

      In general, this method should be used instead of getOutputShape(ToShapeId) when getting the output of operations that are known to exist.

      Parameters:
      operation - Operation to get the output of.
      Returns:
      Returns the output shape of the operation.
      Throws:
      ExpectationNotMetException - if the operation shape cannot be found.
    • getOutputMembers

      public Map<String,MemberShape> getOutputMembers(ToShapeId operation)
      Gets the output members of an operation as a map of member names to MemberShape.

      The return map is ordered using the same order defined in the model. If the operation has no output, an empty map is returned.

      Parameters:
      operation - Operation to get the output members of.
      Returns:
      Returns the map of members, or an empty map.
    • isOutputStructure

      public boolean isOutputStructure(ToShapeId structureId)
      Returns true if the given structure is used as output by any operation in the model or is marked with the output trait.
      Parameters:
      structureId - Structure to check.
      Returns:
      Returns true if the structure is used as output.
    • getOutputBindings

      public Set<OperationShape> getOutputBindings(ToShapeId output)
      Gets all the operations that bind the given shape as output.
      Parameters:
      output - The structure that may be used as output.
      Returns:
      Returns a set of operations that bind the given output shape.
    • getErrors

      public List<StructureShape> getErrors(ToShapeId operation)
      Gets the list of error structures defined on an operation.

      An empty list is returned if the operation is not found or has no errors.

      Parameters:
      operation - Operation to get the errors of.
      Returns:
      Returns the list of error structures, or an empty list.
      See Also:
    • getErrors

      public List<StructureShape> getErrors(ToShapeId service, ToShapeId operation)
      Gets the list of error structures defined on an operation, including any common errors inherited from a service shape.

      An empty list is returned if the operation is not found or has no errors.

      Parameters:
      service - Service shape to inherit common errors from.
      operation - Operation to get the errors of.
      Returns:
      Returns the list of error structures, or an empty list.
    • getErrorBindings

      public Set<Shape> getErrorBindings(ToShapeId error)
      Gets all the operations and services that bind the given shape as an error.
      Parameters:
      error - The structure that may be used as an error.
      Returns:
      Returns a set of operations and services that bind the given error shape.