Skip to content

create_data_source async

create_data_source(
    api_id: String,
    name: ResourceName,
    type: DataSourceType,
    *,
    config_overrides: Optional[AsyncAppSyncClientConfig] = None,
    description: Optional[String] = None,
    service_role_arn: Optional[String] = None,
    dynamodb_config: Optional[DynamodbDataSourceConfig] = None,
    lambda_config: Optional[LambdaDataSourceConfig] = None,
    elasticsearch_config: Optional[ElasticsearchDataSourceConfig] = None,
    open_search_service_config: Optional[OpenSearchServiceDataSourceConfig] = None,
    http_config: Optional[HttpDataSourceConfig] = None,
    relational_database_config: Optional[RelationalDatabaseDataSourceConfig] = None,
    event_bridge_config: Optional[EventBridgeDataSourceConfig] = None,
    metrics_config: Optional[DataSourceLevelMetricsConfig] = None,
) -> CreateDataSourceResponse

Creates a DataSource object.

Parameters:

  • api_id (String) –

    The API ID for the GraphQL API for the DataSource.

  • name (ResourceName) –

    A user-supplied name for the DataSource.

  • description (Optional[String], default: None ) –

    A description of the DataSource.

  • type (DataSourceType) –

    The type of the DataSource.

  • service_role_arn (Optional[String], default: None ) –

    The Identity and Access Management (IAM) service role Amazon Resource Name (ARN) for the data source. The system assumes this role when accessing the data source.

  • dynamodb_config (Optional[DynamodbDataSourceConfig], default: None ) –

    Amazon DynamoDB settings.

  • lambda_config (Optional[LambdaDataSourceConfig], default: None ) –

    Lambda settings.

  • elasticsearch_config (Optional[ElasticsearchDataSourceConfig], default: None ) –

    Amazon OpenSearch Service settings.

    As of September 2021, Amazon Elasticsearch service is Amazon OpenSearch Service. This configuration is deprecated. For new data sources, use CreateDataSourceRequest$openSearchServiceConfig to create an OpenSearch data source.

  • open_search_service_config (Optional[OpenSearchServiceDataSourceConfig], default: None ) –

    Amazon OpenSearch Service settings.

  • http_config (Optional[HttpDataSourceConfig], default: None ) –

    HTTP endpoint settings.

  • relational_database_config (Optional[RelationalDatabaseDataSourceConfig], default: None ) –

    Relational database settings.

  • event_bridge_config (Optional[EventBridgeDataSourceConfig], default: None ) –

    Amazon EventBridge settings.

  • metrics_config (Optional[DataSourceLevelMetricsConfig], default: None ) –

    Enables or disables enhanced data source metrics for specified data sources. Note that metricsConfig won't be used unless the dataSourceLevelMetricsBehavior value is set to PER_DATA_SOURCE_METRICS. If the dataSourceLevelMetricsBehavior is set to FULL_REQUEST_DATA_SOURCE_METRICS instead, metricsConfig will be ignored. However, you can still set its value.

    metricsConfig can be ENABLED or DISABLED.

Raises:

  • BadRequestException –

    The request is not well formed. For example, a value is invalid or a required field is missing. Check the field values, and then try again.

  • ConcurrentModificationException –

    Another modification is in progress at this time and it must complete before you can make your change.

  • InternalFailureException –

    An internal AppSync error occurred. Try your request again.

  • NotFoundException –

    The resource specified in the request was not found. Check the resource, and then try again.

  • UnauthorizedException –

    You aren't authorized to perform this operation.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_appsync/_services/async_app_sync.py
async def create_data_source(
    self,
    api_id: "capo_appsync.types.string.String",
    name: "capo_appsync.types.resource_name.ResourceName",
    type: "capo_appsync.types.data_source_type.DataSourceType",
    *,
    config_overrides: Optional[AsyncAppSyncClientConfig] = None,
    description: Optional["capo_appsync.types.string.String"] = None,
    service_role_arn: Optional["capo_appsync.types.string.String"] = None,
    dynamodb_config: Optional[
        "capo_appsync.types.dynamodb_data_source_config.DynamodbDataSourceConfig"
    ] = None,
    lambda_config: Optional[
        "capo_appsync.types.lambda_data_source_config.LambdaDataSourceConfig"
    ] = None,
    elasticsearch_config: Optional[
        "capo_appsync.types.elasticsearch_data_source_config.ElasticsearchDataSourceConfig"
    ] = None,
    open_search_service_config: Optional[
        "capo_appsync.types.open_search_service_data_source_config.OpenSearchServiceDataSourceConfig"
    ] = None,
    http_config: Optional[
        "capo_appsync.types.http_data_source_config.HttpDataSourceConfig"
    ] = None,
    relational_database_config: Optional[
        "capo_appsync.types.relational_database_data_source_config.RelationalDatabaseDataSourceConfig"
    ] = None,
    event_bridge_config: Optional[
        "capo_appsync.types.event_bridge_data_source_config.EventBridgeDataSourceConfig"
    ] = None,
    metrics_config: Optional[
        "capo_appsync.types.data_source_level_metrics_config.DataSourceLevelMetricsConfig"
    ] = None,
) -> "capo_appsync.types.create_data_source_response.CreateDataSourceResponse":
    """<p>Creates a <code>DataSource</code> object.</p>

    Args:
        api_id: <p>The API ID for the GraphQL API for the <code>DataSource</code>.</p>
        name: <p>A user-supplied name for the <code>DataSource</code>.</p>
        description: <p>A description of the <code>DataSource</code>.</p>
        type: <p>The type of the <code>DataSource</code>.</p>
        service_role_arn: <p>The Identity and Access Management (IAM) service role Amazon Resource Name (ARN) for the data source. The system assumes this role when accessing the data source.</p>
        dynamodb_config: <p>Amazon DynamoDB settings.</p>
        lambda_config: <p>Lambda settings.</p>
        elasticsearch_config: <p>Amazon OpenSearch Service settings.</p> <p>As of September 2021, Amazon Elasticsearch service is Amazon OpenSearch Service. This configuration is deprecated. For new data sources, use <a>CreateDataSourceRequest$openSearchServiceConfig</a> to create an OpenSearch data source.</p>
        open_search_service_config: <p>Amazon OpenSearch Service settings.</p>
        http_config: <p>HTTP endpoint settings.</p>
        relational_database_config: <p>Relational database settings.</p>
        event_bridge_config: <p>Amazon EventBridge settings.</p>
        metrics_config: <p>Enables or disables enhanced data source metrics for specified data sources. Note that <code>metricsConfig</code> won't be used unless the <code>dataSourceLevelMetricsBehavior</code> value is set to <code>PER_DATA_SOURCE_METRICS</code>. If the <code>dataSourceLevelMetricsBehavior</code> is set to <code>FULL_REQUEST_DATA_SOURCE_METRICS</code> instead, <code>metricsConfig</code> will be ignored. However, you can still set its value.</p> <p> <code>metricsConfig</code> can be <code>ENABLED</code> or <code>DISABLED</code>.</p>

    Raises:
        capo_appsync.errors.bad_request_exception.BadRequestException: <p>The request is not well formed. For example, a value is invalid or a required field is missing. Check the field values, and then try again.</p>
        capo_appsync.errors.concurrent_modification_exception.ConcurrentModificationException: <p>Another modification is in progress at this time and it must complete before you can make your change.</p>
        capo_appsync.errors.internal_failure_exception.InternalFailureException: <p>An internal AppSync error occurred. Try your request again.</p>
        capo_appsync.errors.not_found_exception.NotFoundException: <p>The resource specified in the request was not found. Check the resource, and then try again.</p>
        capo_appsync.errors.unauthorized_exception.UnauthorizedException: <p>You aren't authorized to perform this operation.</p>
        capo_appsync.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_appsync.types.create_data_source_request.CreateDataSourceRequest]",
    ) -> AsyncOperationResponse[
        "capo_appsync.types.create_data_source_response.CreateDataSourceResponse"
    ]:
        import capo_appsync._operations.aws_deepdish_control_plane_service.create_data_source

        (
            output,
            http_response,
        ) = await capo_appsync._operations.aws_deepdish_control_plane_service.create_data_source.async_create_data_source(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateDataSource")
    )
    input_: capo_appsync.types.create_data_source_request.CreateDataSourceRequest = {
        "api_id": api_id,
        "name": name,
        "type": type,
    }
    if description is not None:
        input_["description"] = description
    if service_role_arn is not None:
        input_["service_role_arn"] = service_role_arn
    if dynamodb_config is not None:
        input_["dynamodb_config"] = dynamodb_config
    if lambda_config is not None:
        input_["lambda_config"] = lambda_config
    if elasticsearch_config is not None:
        input_["elasticsearch_config"] = elasticsearch_config
    if open_search_service_config is not None:
        input_["open_search_service_config"] = open_search_service_config
    if http_config is not None:
        input_["http_config"] = http_config
    if relational_database_config is not None:
        input_["relational_database_config"] = relational_database_config
    if event_bridge_config is not None:
        input_["event_bridge_config"] = event_bridge_config
    if metrics_config is not None:
        input_["metrics_config"] = metrics_config

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output