updateDataSource method

Future<UpdateDataSourceResponse> updateDataSource({
  1. required String apiId,
  2. required String name,
  3. required DataSourceType type,
  4. String? description,
  5. DynamodbDataSourceConfig? dynamodbConfig,
  6. ElasticsearchDataSourceConfig? elasticsearchConfig,
  7. EventBridgeDataSourceConfig? eventBridgeConfig,
  8. HttpDataSourceConfig? httpConfig,
  9. LambdaDataSourceConfig? lambdaConfig,
  10. DataSourceLevelMetricsConfig? metricsConfig,
  11. OpenSearchServiceDataSourceConfig? openSearchServiceConfig,
  12. RelationalDatabaseDataSourceConfig? relationalDatabaseConfig,
  13. String? serviceRoleArn,
})

Updates a DataSource object.

May throw BadRequestException. May throw ConcurrentModificationException. May throw InternalFailureException. May throw NotFoundException. May throw UnauthorizedException.

Parameter apiId : The API ID.

Parameter name : The new name for the data source.

Parameter type : The new data source type.

Parameter description : The new description for the data source.

Parameter dynamodbConfig : The new Amazon DynamoDB configuration.

Parameter elasticsearchConfig : The new OpenSearch configuration.

As of September 2021, Amazon Elasticsearch service is Amazon OpenSearch Service. This configuration is deprecated. Instead, use UpdateDataSourceRequest$openSearchServiceConfig to update an OpenSearch data source.

Parameter eventBridgeConfig : The new Amazon EventBridge settings.

Parameter httpConfig : The new HTTP endpoint configuration.

Parameter lambdaConfig : The new Lambda configuration.

Parameter metricsConfig : 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.

Parameter openSearchServiceConfig : The new OpenSearch configuration.

Parameter relationalDatabaseConfig : The new relational database configuration.

Parameter serviceRoleArn : The new service role Amazon Resource Name (ARN) for the data source.

Implementation

Future<UpdateDataSourceResponse> updateDataSource({
  required String apiId,
  required String name,
  required DataSourceType type,
  String? description,
  DynamodbDataSourceConfig? dynamodbConfig,
  ElasticsearchDataSourceConfig? elasticsearchConfig,
  EventBridgeDataSourceConfig? eventBridgeConfig,
  HttpDataSourceConfig? httpConfig,
  LambdaDataSourceConfig? lambdaConfig,
  DataSourceLevelMetricsConfig? metricsConfig,
  OpenSearchServiceDataSourceConfig? openSearchServiceConfig,
  RelationalDatabaseDataSourceConfig? relationalDatabaseConfig,
  String? serviceRoleArn,
}) async {
  final $payload = <String, dynamic>{
    'type': type.value,
    if (description != null) 'description': description,
    if (dynamodbConfig != null) 'dynamodbConfig': dynamodbConfig,
    if (elasticsearchConfig != null)
      'elasticsearchConfig': elasticsearchConfig,
    if (eventBridgeConfig != null) 'eventBridgeConfig': eventBridgeConfig,
    if (httpConfig != null) 'httpConfig': httpConfig,
    if (lambdaConfig != null) 'lambdaConfig': lambdaConfig,
    if (metricsConfig != null) 'metricsConfig': metricsConfig.value,
    if (openSearchServiceConfig != null)
      'openSearchServiceConfig': openSearchServiceConfig,
    if (relationalDatabaseConfig != null)
      'relationalDatabaseConfig': relationalDatabaseConfig,
    if (serviceRoleArn != null) 'serviceRoleArn': serviceRoleArn,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/v1/apis/${Uri.encodeComponent(apiId)}/datasources/${Uri.encodeComponent(name)}',
    exceptionFnMap: _exceptionFns,
  );
  return UpdateDataSourceResponse.fromJson(response);
}