searchThings method

Future<SearchThingsResponse> searchThings({
  1. required String entityId,
  2. int? maxResults,
  3. int? namespaceVersion,
  4. String? nextToken,
})

Searches for things associated with the specified entity. You can search by both device and device model.

For example, if two different devices, camera1 and camera2, implement the camera device model, the user can associate thing1 to camera1 and thing2 to camera2. SearchThings(camera2) will return only thing2, but SearchThings(camera) will return both thing1 and thing2.

This action searches for exact matches and doesn't perform partial text matching.

May throw InvalidRequestException. May throw ResourceNotFoundException. May throw InternalFailureException. May throw ThrottlingException.

Parameter entityId : The ID of the entity to which the things are associated.

The IDs should be in the following format.

urn:tdm:REGION/ACCOUNT ID/default:device:DEVICENAME

Parameter maxResults : The maximum number of results to return in the response.

Parameter namespaceVersion : The version of the user's namespace. Defaults to the latest version of the user's namespace.

Parameter nextToken : The string that specifies the next page of results. Use this when you're paginating results.

Implementation

Future<SearchThingsResponse> searchThings({
  required String entityId,
  int? maxResults,
  int? namespaceVersion,
  String? nextToken,
}) async {
  ArgumentError.checkNotNull(entityId, 'entityId');
  _s.validateStringLength(
    'entityId',
    entityId,
    0,
    160,
    isRequired: true,
  );
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    250,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'IotThingsGraphFrontEndService.SearchThings'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'entityId': entityId,
      if (maxResults != null) 'maxResults': maxResults,
      if (namespaceVersion != null) 'namespaceVersion': namespaceVersion,
      if (nextToken != null) 'nextToken': nextToken,
    },
  );

  return SearchThingsResponse.fromJson(jsonResponse.body);
}