discoverInstances method

Future<DiscoverInstancesResponse> discoverInstances({
  1. required String namespaceName,
  2. required String serviceName,
  3. HealthStatusFilter? healthStatus,
  4. int? maxResults,
  5. Map<String, String>? optionalParameters,
  6. Map<String, String>? queryParameters,
})

Discovers registered instances for a specified namespace and service. You can use DiscoverInstances to discover instances for any type of namespace. For public and private DNS namespaces, you can also use DNS queries to discover instances.

May throw ServiceNotFound. May throw NamespaceNotFound. May throw InvalidInput. May throw RequestLimitExceeded.

Parameter namespaceName : The name of the namespace that you specified when you registered the instance.

Parameter serviceName : The name of the service that you specified when you registered the instance.

Parameter healthStatus : The health status of the instances that you want to discover.

Parameter maxResults : The maximum number of instances that you want AWS Cloud Map to return in the response to a DiscoverInstances request. If you don't specify a value for MaxResults, AWS Cloud Map returns up to 100 instances.

Parameter optionalParameters : Opportunistic filters to scope the results based on custom attributes. If there are instances that match both the filters specified in both the QueryParameters parameter and this parameter, they are returned. Otherwise, these filters are ignored and only instances that match the filters specified in the QueryParameters parameter are returned.

Parameter queryParameters : Filters to scope the results based on custom attributes for the instance. For example, {version=v1, az=1a}. Only instances that match all the specified key-value pairs will be returned.

Implementation

Future<DiscoverInstancesResponse> discoverInstances({
  required String namespaceName,
  required String serviceName,
  HealthStatusFilter? healthStatus,
  int? maxResults,
  Map<String, String>? optionalParameters,
  Map<String, String>? queryParameters,
}) async {
  ArgumentError.checkNotNull(namespaceName, 'namespaceName');
  _s.validateStringLength(
    'namespaceName',
    namespaceName,
    0,
    1024,
    isRequired: true,
  );
  ArgumentError.checkNotNull(serviceName, 'serviceName');
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    1000,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'Route53AutoNaming_v20170314.DiscoverInstances'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'NamespaceName': namespaceName,
      'ServiceName': serviceName,
      if (healthStatus != null) 'HealthStatus': healthStatus.toValue(),
      if (maxResults != null) 'MaxResults': maxResults,
      if (optionalParameters != null)
        'OptionalParameters': optionalParameters,
      if (queryParameters != null) 'QueryParameters': queryParameters,
    },
  );

  return DiscoverInstancesResponse.fromJson(jsonResponse.body);
}