listBackendEnvironments method

Future<ListBackendEnvironmentsResult> listBackendEnvironments({
  1. required String appId,
  2. String? environmentName,
  3. int? maxResults,
  4. String? nextToken,
})

Lists the backend environments for an Amplify app.

This API is available only to Amplify Gen 1 applications where the backend is created using Amplify Studio or the Amplify command line interface (CLI). This API isn’t available to Amplify Gen 2 applications. When you deploy an application with Amplify Gen 2, you provision the app's backend infrastructure using Typescript code.

May throw BadRequestException. May throw InternalFailureException. May throw UnauthorizedException.

Parameter appId : The unique ID for an Amplify app.

Parameter environmentName : The name of the backend environment

Parameter maxResults : The maximum number of records to list in a single response.

Parameter nextToken : A pagination token. Set to null to start listing backend environments from the start. If a non-null pagination token is returned in a result, pass its value in here to list more backend environments.

Implementation

Future<ListBackendEnvironmentsResult> listBackendEnvironments({
  required String appId,
  String? environmentName,
  int? maxResults,
  String? nextToken,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    0,
    50,
  );
  final $query = <String, List<String>>{
    if (environmentName != null) 'environmentName': [environmentName],
    if (maxResults != null) 'maxResults': [maxResults.toString()],
    if (nextToken != null) 'nextToken': [nextToken],
  };
  final response = await _protocol.send(
    payload: null,
    method: 'GET',
    requestUri: '/apps/${Uri.encodeComponent(appId)}/backendenvironments',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  return ListBackendEnvironmentsResult.fromJson(response);
}