addTagsToResource method

Future<AddTagsToResourceOutput> addTagsToResource({
  1. required String resourceARN,
  2. required List<Tag> tags,
})

Adds one or more tags to the specified resource. You use tags to add metadata to resources, which you can use to categorize these resources. For example, you can categorize resources by purpose, owner, environment, or team. Each tag consists of a key and a value, which you define. You can add tags to the following AWS Storage Gateway resources:

  • Storage gateways of all types
  • Storage volumes
  • Virtual tapes
  • NFS and SMB file shares
You can create a maximum of 50 tags for each resource. Virtual tapes and storage volumes that are recovered to a new gateway maintain their tags.

May throw InvalidGatewayRequestException. May throw InternalServerError.

Parameter resourceARN : The Amazon Resource Name (ARN) of the resource you want to add tags to.

Parameter tags : The key-value pair that represents the tag you want to add to the resource. The value can be an empty string.

Implementation

Future<AddTagsToResourceOutput> addTagsToResource({
  required String resourceARN,
  required List<Tag> tags,
}) async {
  ArgumentError.checkNotNull(resourceARN, 'resourceARN');
  _s.validateStringLength(
    'resourceARN',
    resourceARN,
    50,
    500,
    isRequired: true,
  );
  ArgumentError.checkNotNull(tags, 'tags');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'StorageGateway_20130630.AddTagsToResource'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ResourceARN': resourceARN,
      'Tags': tags,
    },
  );

  return AddTagsToResourceOutput.fromJson(jsonResponse.body);
}