createBackendEnvironment method

Future<CreateBackendEnvironmentResult> createBackendEnvironment({
  1. required String appId,
  2. required String environmentName,
  3. String? deploymentArtifacts,
  4. String? stackName,
})

Creates a new backend environment for an Amplify app.

May throw BadRequestException. May throw UnauthorizedException. May throw NotFoundException. May throw InternalFailureException. May throw LimitExceededException.

Parameter appId : The unique ID for an Amplify app.

Parameter environmentName : The name for the backend environment.

Parameter deploymentArtifacts : The name of deployment artifacts.

Parameter stackName : The AWS CloudFormation stack name of a backend environment.

Implementation

Future<CreateBackendEnvironmentResult> createBackendEnvironment({
  required String appId,
  required String environmentName,
  String? deploymentArtifacts,
  String? stackName,
}) async {
  ArgumentError.checkNotNull(appId, 'appId');
  _s.validateStringLength(
    'appId',
    appId,
    1,
    20,
    isRequired: true,
  );
  ArgumentError.checkNotNull(environmentName, 'environmentName');
  _s.validateStringLength(
    'environmentName',
    environmentName,
    1,
    255,
    isRequired: true,
  );
  _s.validateStringLength(
    'deploymentArtifacts',
    deploymentArtifacts,
    1,
    1000,
  );
  _s.validateStringLength(
    'stackName',
    stackName,
    1,
    255,
  );
  final $payload = <String, dynamic>{
    'environmentName': environmentName,
    if (deploymentArtifacts != null)
      'deploymentArtifacts': deploymentArtifacts,
    if (stackName != null) 'stackName': stackName,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/apps/${Uri.encodeComponent(appId)}/backendenvironments',
    exceptionFnMap: _exceptionFns,
  );
  return CreateBackendEnvironmentResult.fromJson(response);
}