attachThingPrincipal method

Future<void> attachThingPrincipal({
  1. required String principal,
  2. required String thingName,
})

Attaches the specified principal to the specified thing. A principal can be X.509 certificates, IAM users, groups, and roles, Amazon Cognito identities or federated identities.

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

Parameter principal : The principal, which can be a certificate ARN (as returned from the CreateCertificate operation) or an Amazon Cognito ID.

Parameter thingName : The name of the thing.

Implementation

Future<void> attachThingPrincipal({
  required String principal,
  required String thingName,
}) async {
  ArgumentError.checkNotNull(principal, 'principal');
  ArgumentError.checkNotNull(thingName, 'thingName');
  _s.validateStringLength(
    'thingName',
    thingName,
    1,
    128,
    isRequired: true,
  );
  final headers = <String, String>{
    'x-amzn-principal': principal.toString(),
  };
  final response = await _protocol.send(
    payload: null,
    method: 'PUT',
    requestUri: '/things/${Uri.encodeComponent(thingName)}/principals',
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
}