listThingPrincipalsV2 method

Future<ListThingPrincipalsV2Response> listThingPrincipalsV2({
  1. required String thingName,
  2. int? maxResults,
  3. String? nextToken,
  4. ThingPrincipalType? thingPrincipalType,
})

Lists the principals associated with the specified thing. A principal can be an X.509 certificate or an Amazon Cognito ID.

Requires permission to access the ListThingPrincipals action.

May throw InternalFailureException. May throw InvalidRequestException. May throw ResourceNotFoundException. May throw ServiceUnavailableException. May throw ThrottlingException. May throw UnauthorizedException.

Parameter thingName : The name of the thing.

Parameter maxResults : The maximum number of results to return in this operation.

Parameter nextToken : To retrieve the next set of results, the nextToken value from a previous response; otherwise null to receive the first set of results.

Parameter thingPrincipalType : The type of the relation you want to filter in the response. If no value is provided in this field, the response will list all principals, including both the EXCLUSIVE_THING and NON_EXCLUSIVE_THING attachment types.

  • EXCLUSIVE_THING - Attaches the specified principal to the specified thing, exclusively. The thing will be the only thing that’s attached to the principal.
  • NON_EXCLUSIVE_THING - Attaches the specified principal to the specified thing. Multiple things can be attached to the principal.

Implementation

Future<ListThingPrincipalsV2Response> listThingPrincipalsV2({
  required String thingName,
  int? maxResults,
  String? nextToken,
  ThingPrincipalType? thingPrincipalType,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    250,
  );
  final $query = <String, List<String>>{
    if (maxResults != null) 'maxResults': [maxResults.toString()],
    if (nextToken != null) 'nextToken': [nextToken],
    if (thingPrincipalType != null)
      'thingPrincipalType': [thingPrincipalType.value],
  };
  final response = await _protocol.send(
    payload: null,
    method: 'GET',
    requestUri: '/things/${Uri.encodeComponent(thingName)}/principals-v2',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  return ListThingPrincipalsV2Response.fromJson(response);
}