public final class ServiceIndex extends java.lang.Object implements KnowledgeIndex
This index can be used to get all of the protocol traits applied to a service, to get all of the auth defining traits applied to a service, to get the effective authentication schemes of a service, and to get the effective authentication schemes of an operation bound within the closure of a service.
| Modifier and Type | Class and Description |
|---|---|
static class |
ServiceIndex.AuthSchemeMode
Defines the type of auth schemes returned by
getEffectiveAuthSchemes(software.amazon.smithy.model.shapes.ToShapeId). |
| Constructor and Description |
|---|
ServiceIndex(Model model) |
| Modifier and Type | Method and Description |
|---|---|
java.util.Map<ShapeId,Trait> |
getAuthSchemes(ToShapeId service)
Get all auth defining traits attached to a service or operation.
|
java.util.Map<ShapeId,Trait> |
getEffectiveAuthSchemes(ToShapeId service)
Gets a list of effective authentication schemes applied to a service.
|
java.util.Map<ShapeId,Trait> |
getEffectiveAuthSchemes(ToShapeId service,
ServiceIndex.AuthSchemeMode authSchemeMode)
Gets a list of effective authentication schemes applied to a service, based on the AuthSchemeMode.
|
java.util.Map<ShapeId,Trait> |
getEffectiveAuthSchemes(ToShapeId service,
ToShapeId operation)
Gets a list of effective authentication schemes applied to an operation
bound within a service.
|
java.util.Map<ShapeId,Trait> |
getEffectiveAuthSchemes(ToShapeId service,
ToShapeId operation,
ServiceIndex.AuthSchemeMode authSchemeMode)
Gets a list of effective authentication schemes applied to an operation
bound within a service, based on the AuthSchemeMode.
|
java.util.Map<ShapeId,Trait> |
getProtocols(ToShapeId service)
Get all protocol traits attached to a service.
|
static ServiceIndex |
of(Model model) |
public ServiceIndex(Model model)
public static ServiceIndex of(Model model)
public java.util.Map<ShapeId,Trait> getProtocols(ToShapeId service)
A protocol trait is a trait that is marked with
the smithy.api#protocolDefinition trait.
An empty map is returned if service cannot be found in the
model or is not a service shape.
service - Service to get the protocols of.public java.util.Map<ShapeId,Trait> getAuthSchemes(ToShapeId service)
An auth defining trait is a trait that is marked with
the smithy.api#authDefinition trait.
The returned map is ordered alphabetically by absolute shape ID.
An empty map is returned if id cannot be found in the
model or is not a service shape.
service - Service to get the auth schemes of.public java.util.Map<ShapeId,Trait> getEffectiveAuthSchemes(ToShapeId service)
An effective authentication scheme is derived from the
smithy.api#auth trait and the auth defining traits applied
to a service. If the service has the smithy.api#auth trait,
then a map is returned that contains the traits applied to the service
that matches the values in the auth trait. If no auth trait is applied,
then all of the auth defining traits on the service are returned.
The returned map is provided in the same order as the values in the
auth trait if an auth trait is present, otherwise the result
returned is ordered alphabetically by absolute shape ID.
An empty map is returned if service cannot be found in the
model or is not a service shape.
service - Service to get the effective authentication schemes of.public java.util.Map<ShapeId,Trait> getEffectiveAuthSchemes(ToShapeId service, ServiceIndex.AuthSchemeMode authSchemeMode)
If AuthSchemeMode is MODELED, which is the default, the behavior is same as
getEffectiveAuthSchemes(ToShapeId).
If AuthSchemeMode is NO_AUTH_AWARE, the behavior is same, except that if the service has no effective
auth schemes, instead of an empty map, it returns the smithy.api#noAuth auth scheme. It avoids having to
special case handling an empty result. The returned map will always contain at least 1 entry.
service - Service to get the effective authentication schemes of.authSchemeMode - AuthSchemeMode to determine which authentication schemes to include.public java.util.Map<ShapeId,Trait> getEffectiveAuthSchemes(ToShapeId service, ToShapeId operation)
If the given operation defines that smithy.api#auth trait,
then a map is returned that consists of the traits applied to the
service that match the values of the smithy.api#auth trait. If
the operation does not define an smithy.api#auth trait, then
the effective auth schemes of the service is returned (that is, the
return value of getEffectiveAuthSchemes(ToShapeId)).
The returned map is provided in the same order as the values in the
auth trait if an auth trait is present, otherwise the result
returned is ordered alphabetically by absolute shape ID.
An empty map is returned if service shape cannot be found
in the model or is not a service shape. An empty map is returned if
operation cannot be found in the model or is not an operation
shape.
service - Service the operation is within.operation - Operation to get the effective authentication schemes of.public java.util.Map<ShapeId,Trait> getEffectiveAuthSchemes(ToShapeId service, ToShapeId operation, ServiceIndex.AuthSchemeMode authSchemeMode)
If AuthSchemeMode is MODELED, which is the default, the behavior is same as
getEffectiveAuthSchemes(ToShapeId, ToShapeId).
If AuthSchemeMode is NO_AUTH_AWARE, the behavior is same, with the following differences:
If the operation has no effective auth schemes, instead of an empty map, it returns the smithy.api#noAuth
auth scheme.
If the operation has the smithy.api#optionalAuth trait, it adds smithy.api#noAuth to the end.
Using NO_AUTH_AWARE accounts for smithy.api#optionalAuth and avoids having to special case
handling an empty result. The returned map will always contain at least 1 entry.
The smithy.api#noAuth scheme, if present, is always the last scheme.
service - Service the operation is within.operation - Operation to get the effective authentication schemes of.authSchemeMode - AuthSchemeMode to determine which authentication schemes to include.