createDataSource method
- required String apiId,
- required String name,
- required DataSourceType type,
- String? description,
- DynamodbDataSourceConfig? dynamodbConfig,
- ElasticsearchDataSourceConfig? elasticsearchConfig,
- HttpDataSourceConfig? httpConfig,
- LambdaDataSourceConfig? lambdaConfig,
- RelationalDatabaseDataSourceConfig? relationalDatabaseConfig,
- String? serviceRoleArn,
Creates a DataSource
object.
May throw BadRequestException. May throw ConcurrentModificationException. May throw NotFoundException. May throw UnauthorizedException. May throw InternalFailureException.
Parameter apiId
:
The API ID for the GraphQL API for the DataSource
.
Parameter name
:
A user-supplied name for the DataSource
.
Parameter type
:
The type of the DataSource
.
Parameter description
:
A description of the DataSource
.
Parameter dynamodbConfig
:
Amazon DynamoDB settings.
Parameter elasticsearchConfig
:
Amazon Elasticsearch Service settings.
Parameter httpConfig
:
HTTP endpoint settings.
Parameter lambdaConfig
:
AWS Lambda settings.
Parameter relationalDatabaseConfig
:
Relational database settings.
Parameter serviceRoleArn
:
The AWS IAM service role ARN for the data source. The system assumes this
role when accessing the data source.
Implementation
Future<CreateDataSourceResponse> createDataSource({
required String apiId,
required String name,
required DataSourceType type,
String? description,
DynamodbDataSourceConfig? dynamodbConfig,
ElasticsearchDataSourceConfig? elasticsearchConfig,
HttpDataSourceConfig? httpConfig,
LambdaDataSourceConfig? lambdaConfig,
RelationalDatabaseDataSourceConfig? relationalDatabaseConfig,
String? serviceRoleArn,
}) async {
ArgumentError.checkNotNull(apiId, 'apiId');
ArgumentError.checkNotNull(name, 'name');
_s.validateStringLength(
'name',
name,
1,
65536,
isRequired: true,
);
ArgumentError.checkNotNull(type, 'type');
final $payload = <String, dynamic>{
'name': name,
'type': type.toValue(),
if (description != null) 'description': description,
if (dynamodbConfig != null) 'dynamodbConfig': dynamodbConfig,
if (elasticsearchConfig != null)
'elasticsearchConfig': elasticsearchConfig,
if (httpConfig != null) 'httpConfig': httpConfig,
if (lambdaConfig != null) 'lambdaConfig': lambdaConfig,
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',
exceptionFnMap: _exceptionFns,
);
return CreateDataSourceResponse.fromJson(response);
}