cloudshift.awscdk.dsl.services.appsync.EventBridgeDataSourceDsl.kt Maven / Gradle / Ivy
@file:Suppress("RedundantVisibilityModifier","RedundantUnitReturnType","RemoveRedundantQualifierName","unused","UnusedImport","ClassName","REDUNDANT_PROJECTION","DEPRECATION")
package cloudshift.awscdk.dsl.services.appsync
import cloudshift.awscdk.common.CdkDslMarker
import kotlin.String
import software.amazon.awscdk.services.appsync.EventBridgeDataSource
import software.amazon.awscdk.services.appsync.IGraphqlApi
import software.amazon.awscdk.services.events.IEventBus
import software.amazon.awscdk.services.iam.IRole
import software.constructs.Construct
/**
* An AppSync datasource backed by EventBridge.
*
* Example:
*
* ```
* import software.amazon.awscdk.services.events.*;
* GraphqlApi api = GraphqlApi.Builder.create(this, "EventBridgeApi")
* .name("EventBridgeApi")
* .schema(SchemaFile.fromAsset(join(__dirname, "appsync.eventbridge.graphql")))
* .build();
* EventBus bus = EventBus.Builder.create(this, "DestinationEventBus").build();
* EventBridgeDataSource dataSource = api.addEventBridgeDataSource("NoneDS", bus);
* dataSource.createResolver("EventResolver", BaseResolverProps.builder()
* .typeName("Mutation")
* .fieldName("emitEvent")
* .requestMappingTemplate(MappingTemplate.fromFile("request.vtl"))
* .responseMappingTemplate(MappingTemplate.fromFile("response.vtl"))
* .build());
* ```
*/
@CdkDslMarker
public class EventBridgeDataSourceDsl(
scope: Construct,
id: String,
) {
private val cdkBuilder: EventBridgeDataSource.Builder =
EventBridgeDataSource.Builder.create(scope, id)
/**
* The API to attach this data source to.
*
* @param api The API to attach this data source to.
*/
public fun api(api: IGraphqlApi) {
cdkBuilder.api(api)
}
/**
* the description of the data source.
*
* Default: - None
*
* @param description the description of the data source.
*/
public fun description(description: String) {
cdkBuilder.description(description)
}
/**
* The EventBridge EventBus.
*
* @param eventBus The EventBridge EventBus.
*/
public fun eventBus(eventBus: IEventBus) {
cdkBuilder.eventBus(eventBus)
}
/**
* The name of the data source.
*
* Default: - id of data source
*
* @param name The name of the data source.
*/
public fun name(name: String) {
cdkBuilder.name(name)
}
/**
* The IAM service role to be assumed by AppSync to interact with the data source.
*
* Default: - Create a new role
*
* @param serviceRole The IAM service role to be assumed by AppSync to interact with the data
* source.
*/
public fun serviceRole(serviceRole: IRole) {
cdkBuilder.serviceRole(serviceRole)
}
public fun build(): EventBridgeDataSource = cdkBuilder.build()
}