All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awscdk.services.appsync.RdsDataSource Maven / Gradle / Ivy

There is a newer version: 1.204.0
Show newest version
package software.amazon.awscdk.services.appsync;

/**
 * (experimental) An AppSync datasource backed by RDS.
 * 

* Example: *

*

 * // Build a data source for AppSync to access the database.
 * GraphqlApi api;
 * // Create username and password secret for DB Cluster
 * DatabaseSecret secret = DatabaseSecret.Builder.create(this, "AuroraSecret")
 *         .username("clusteradmin")
 *         .build();
 * // The VPC to place the cluster in
 * Vpc vpc = new Vpc(this, "AuroraVpc");
 * // Create the serverless cluster, provide all values needed to customise the database.
 * ServerlessCluster cluster = ServerlessCluster.Builder.create(this, "AuroraCluster")
 *         .engine(DatabaseClusterEngine.AURORA_MYSQL)
 *         .vpc(vpc)
 *         .credentials(Map.of("username", "clusteradmin"))
 *         .clusterIdentifier("db-endpoint-test")
 *         .defaultDatabaseName("demos")
 *         .build();
 * RdsDataSource rdsDS = api.addRdsDataSource("rds", cluster, secret, "demos");
 * // Set up a resolver for an RDS query.
 * rdsDS.createResolver(BaseResolverProps.builder()
 *         .typeName("Query")
 *         .fieldName("getDemosRds")
 *         .requestMappingTemplate(MappingTemplate.fromString("\n  {\n    \"version\": \"2018-05-29\",\n    \"statements\": [\n      \"SELECT * FROM demos\"\n    ]\n  }\n  "))
 *         .responseMappingTemplate(MappingTemplate.fromString("\n    $utils.toJson($utils.rds.toJsonObject($ctx.result)[0])\n  "))
 *         .build());
 * // Set up a resolver for an RDS mutation.
 * rdsDS.createResolver(BaseResolverProps.builder()
 *         .typeName("Mutation")
 *         .fieldName("addDemoRds")
 *         .requestMappingTemplate(MappingTemplate.fromString("\n  {\n    \"version\": \"2018-05-29\",\n    \"statements\": [\n      \"INSERT INTO demos VALUES (:id, :version)\",\n      \"SELECT * WHERE id = :id\"\n    ],\n    \"variableMap\": {\n      \":id\": $util.toJson($util.autoId()),\n      \":version\": $util.toJson($ctx.args.version)\n    }\n  }\n  "))
 *         .responseMappingTemplate(MappingTemplate.fromString("\n    $utils.toJson($utils.rds.toJsonObject($ctx.result)[1][0])\n  "))
 *         .build());
 * 
*/ @javax.annotation.Generated(value = "jsii-pacmak/1.72.0 (build 4b8828b)", date = "2023-01-03T16:22:41.866Z") @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) @software.amazon.jsii.Jsii(module = software.amazon.awscdk.services.appsync.$Module.class, fqn = "@aws-cdk/aws-appsync.RdsDataSource") public class RdsDataSource extends software.amazon.awscdk.services.appsync.BackedDataSource { protected RdsDataSource(final software.amazon.jsii.JsiiObjectRef objRef) { super(objRef); } protected RdsDataSource(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { super(initializationMode); } /** * @param scope This parameter is required. * @param id This parameter is required. * @param props This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public RdsDataSource(final @org.jetbrains.annotations.NotNull software.constructs.Construct scope, final @org.jetbrains.annotations.NotNull java.lang.String id, final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.appsync.RdsDataSourceProps props) { super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this, new Object[] { java.util.Objects.requireNonNull(scope, "scope is required"), java.util.Objects.requireNonNull(id, "id is required"), java.util.Objects.requireNonNull(props, "props is required") }); } /** * (experimental) A fluent builder for {@link software.amazon.awscdk.services.appsync.RdsDataSource}. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public static final class Builder implements software.amazon.jsii.Builder { /** * @return a new instance of {@link Builder}. * @param scope This parameter is required. * @param id This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public static Builder create(final software.constructs.Construct scope, final java.lang.String id) { return new Builder(scope, id); } private final software.constructs.Construct scope; private final java.lang.String id; private final software.amazon.awscdk.services.appsync.RdsDataSourceProps.Builder props; private Builder(final software.constructs.Construct scope, final java.lang.String id) { this.scope = scope; this.id = id; this.props = new software.amazon.awscdk.services.appsync.RdsDataSourceProps.Builder(); } /** * (experimental) The API to attach this data source to. *

* @return {@code this} * @param api The API to attach this data source to. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder api(final software.amazon.awscdk.services.appsync.IGraphqlApi api) { this.props.api(api); return this; } /** * (experimental) the description of the data source. *

* Default: - None *

* @return {@code this} * @param description the description of the data source. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder description(final java.lang.String description) { this.props.description(description); return this; } /** * (experimental) The name of the data source. *

* Default: - id of data source *

* @return {@code this} * @param name The name of the data source. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder name(final java.lang.String name) { this.props.name(name); return this; } /** * (experimental) The IAM service role to be assumed by AppSync to interact with the data source. *

* Default: - Create a new role *

* @return {@code this} * @param serviceRole The IAM service role to be assumed by AppSync to interact with the data source. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder serviceRole(final software.amazon.awscdk.services.iam.IRole serviceRole) { this.props.serviceRole(serviceRole); return this; } /** * (experimental) The secret containing the credentials for the database. *

* @return {@code this} * @param secretStore The secret containing the credentials for the database. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder secretStore(final software.amazon.awscdk.services.secretsmanager.ISecret secretStore) { this.props.secretStore(secretStore); return this; } /** * (experimental) The serverless cluster to call to interact with this data source. *

* @return {@code this} * @param serverlessCluster The serverless cluster to call to interact with this data source. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder serverlessCluster(final software.amazon.awscdk.services.rds.IServerlessCluster serverlessCluster) { this.props.serverlessCluster(serverlessCluster); return this; } /** * (experimental) The name of the database to use within the cluster. *

* Default: - None *

* @return {@code this} * @param databaseName The name of the database to use within the cluster. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder databaseName(final java.lang.String databaseName) { this.props.databaseName(databaseName); return this; } /** * @returns a newly built instance of {@link software.amazon.awscdk.services.appsync.RdsDataSource}. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) @Override public software.amazon.awscdk.services.appsync.RdsDataSource build() { return new software.amazon.awscdk.services.appsync.RdsDataSource( this.scope, this.id, this.props.build() ); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy