createThingGroup method

Future<CreateThingGroupResponse> createThingGroup({
  1. required String thingGroupName,
  2. String? parentGroupName,
  3. List<Tag>? tags,
  4. ThingGroupProperties? thingGroupProperties,
})

Create a thing group.

May throw InvalidRequestException. May throw ResourceAlreadyExistsException. May throw ThrottlingException. May throw InternalFailureException.

Parameter thingGroupName : The thing group name to create.

Parameter parentGroupName : The name of the parent thing group.

Parameter tags : Metadata which can be used to manage the thing group.

Parameter thingGroupProperties : The thing group properties.

Implementation

Future<CreateThingGroupResponse> createThingGroup({
  required String thingGroupName,
  String? parentGroupName,
  List<Tag>? tags,
  ThingGroupProperties? thingGroupProperties,
}) async {
  ArgumentError.checkNotNull(thingGroupName, 'thingGroupName');
  _s.validateStringLength(
    'thingGroupName',
    thingGroupName,
    1,
    128,
    isRequired: true,
  );
  _s.validateStringLength(
    'parentGroupName',
    parentGroupName,
    1,
    128,
  );
  final $payload = <String, dynamic>{
    if (parentGroupName != null) 'parentGroupName': parentGroupName,
    if (tags != null) 'tags': tags,
    if (thingGroupProperties != null)
      'thingGroupProperties': thingGroupProperties,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/thing-groups/${Uri.encodeComponent(thingGroupName)}',
    exceptionFnMap: _exceptionFns,
  );
  return CreateThingGroupResponse.fromJson(response);
}