OpenSearchDataSource
- class aws_cdk.aws_appsync.OpenSearchDataSource(scope, id, *, domain, service_role=None, api, description=None, name=None)
Bases:
BackedDataSource
(experimental) An Appsync datasource backed by OpenSearch.
- Stability:
experimental
- ExampleMetadata:
infused
Example:
import aws_cdk.aws_opensearchservice as opensearch # api: appsync.GraphqlApi user = iam.User(self, "User") domain = opensearch.Domain(self, "Domain", version=opensearch.EngineVersion.OPENSEARCH_1_2, removal_policy=RemovalPolicy.DESTROY, fine_grained_access_control=opensearch.AdvancedSecurityOptions(master_user_arn=user.user_arn), encryption_at_rest=opensearch.EncryptionAtRestOptions(enabled=True), node_to_node_encryption=True, enforce_https=True ) ds = api.add_open_search_data_source("ds", domain) ds.create_resolver( type_name="Query", field_name="getTests", request_mapping_template=appsync.MappingTemplate.from_string(JSON.stringify({ "version": "2017-02-28", "operation": "GET", "path": "/id/post/_search", "params": { "headers": {}, "query_string": {}, "body": {"from": 0, "size": 50} } })), response_mapping_template=appsync.MappingTemplate.from_string("""[ #foreach($entry in $context.result.hits.hits) #if( $velocityCount > 1 ) , #end $utils.toJson($entry.get("_source")) #end ]""") )
- Parameters:
scope (
Construct
) –id (
str
) –domain (
IDomain
) – (experimental) The OpenSearch domain containing the endpoint for the data source.service_role (
Optional
[IRole
]) – (experimental) The IAM service role to be assumed by AppSync to interact with the data source. Default: - Create a new roleapi (
IGraphqlApi
) – (experimental) The API to attach this data source to.description (
Optional
[str
]) – (experimental) the description of the data source. Default: - Nonename (
Optional
[str
]) – (experimental) The name of the data source. Default: - id of data source
- Stability:
experimental
Methods
- create_function(*, name, description=None, request_mapping_template=None, response_mapping_template=None)
(experimental) creates a new appsync function for this datasource and API using the given properties.
- Parameters:
name (
str
) – (experimental) the name of the AppSync Function.description (
Optional
[str
]) – (experimental) the description for this AppSync Function. Default: - no descriptionrequest_mapping_template (
Optional
[MappingTemplate
]) – (experimental) the request mapping template for the AppSync Function. Default: - no request mapping templateresponse_mapping_template (
Optional
[MappingTemplate
]) – (experimental) the response mapping template for the AppSync Function. Default: - no response mapping template
- Stability:
experimental
- Return type:
- create_resolver(*, field_name, type_name, caching_config=None, pipeline_config=None, request_mapping_template=None, response_mapping_template=None)
(experimental) creates a new resolver for this datasource and API using the given properties.
- Parameters:
field_name (
str
) – (experimental) name of the GraphQL field in the given type this resolver is attached to.type_name (
str
) – (experimental) name of the GraphQL type this resolver is attached to.caching_config (
Union
[CachingConfig
,Dict
[str
,Any
],None
]) – (experimental) The caching configuration for this resolver. Default: - No caching configurationpipeline_config (
Optional
[Sequence
[IAppsyncFunction
]]) – (experimental) configuration of the pipeline resolver. Default: - no pipeline resolver configuration An empty array | undefined sets resolver to be of kind, unitrequest_mapping_template (
Optional
[MappingTemplate
]) – (experimental) The request mapping template for this resolver. Default: - No mapping templateresponse_mapping_template (
Optional
[MappingTemplate
]) – (experimental) The response mapping template for this resolver. Default: - No mapping template
- Stability:
experimental
- Return type:
- to_string()
Returns a string representation of this construct.
- Return type:
str
Attributes
- ds
(experimental) the underlying CFN data source resource.
- Stability:
experimental
- grant_principal
(experimental) the principal of the data source to be IGrantable.
- Stability:
experimental
- name
(experimental) the name of the data source.
- Stability:
experimental
- node
The construct tree node associated with this construct.
Static Methods
- classmethod is_construct(x)
Return whether the given object is a Construct.
- Parameters:
x (
Any
) –- Return type:
bool