listAccounts method

Future<ListAccountsResponse> listAccounts({
  1. required String accessToken,
  2. int? maxResults,
  3. String? nextToken,
})

Lists all AWS accounts assigned to the user. These AWS accounts are assigned by the administrator of the account. For more information, see Assign User Access in the IAM Identity Center User Guide. This operation returns a paginated response.

May throw InvalidRequestException. May throw ResourceNotFoundException. May throw TooManyRequestsException. May throw UnauthorizedException.

Parameter accessToken : The token issued by the CreateToken API call. For more information, see CreateToken in the IAM Identity Center OIDC API Reference Guide.

Parameter maxResults : This is the number of items clients can request per page.

Parameter nextToken : (Optional) When requesting subsequent pages, this is the page token from the previous response output.

Implementation

Future<ListAccountsResponse> listAccounts({
  required String accessToken,
  int? maxResults,
  String? nextToken,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    100,
  );
  final headers = <String, String>{
    'x-amz-sso_bearer_token': accessToken.toString(),
  };
  final $query = <String, List<String>>{
    if (maxResults != null) 'max_result': [maxResults.toString()],
    if (nextToken != null) 'next_token': [nextToken],
  };
  final response = await _protocol.send(
    payload: null,
    method: 'GET',
    requestUri: '/assignment/accounts',
    signed: false,
    queryParams: $query,
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  return ListAccountsResponse.fromJson(response);
}