listContexts method

Future<ListContextsResponse> listContexts({
  1. String? contextType,
  2. DateTime? createdAfter,
  3. DateTime? createdBefore,
  4. int? maxResults,
  5. String? nextToken,
  6. SortContextsBy? sortBy,
  7. SortOrder? sortOrder,
  8. String? sourceUri,
})

Lists the contexts in your account and their properties.

May throw ResourceNotFound.

Parameter contextType : A filter that returns only contexts of the specified type.

Parameter createdAfter : A filter that returns only contexts created on or after the specified time.

Parameter createdBefore : A filter that returns only contexts created on or before the specified time.

Parameter maxResults : The maximum number of contexts to return in the response. The default value is 10.

Parameter nextToken : If the previous call to ListContexts didn't return the full set of contexts, the call returns a token for getting the next set of contexts.

Parameter sortBy : The property used to sort results. The default value is CreationTime.

Parameter sortOrder : The sort order. The default value is Descending.

Parameter sourceUri : A filter that returns only contexts with the specified source URI.

Implementation

Future<ListContextsResponse> listContexts({
  String? contextType,
  DateTime? createdAfter,
  DateTime? createdBefore,
  int? maxResults,
  String? nextToken,
  SortContextsBy? sortBy,
  SortOrder? sortOrder,
  String? sourceUri,
}) async {
  _s.validateStringLength(
    'contextType',
    contextType,
    0,
    256,
  );
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    100,
  );
  _s.validateStringLength(
    'nextToken',
    nextToken,
    0,
    8192,
  );
  _s.validateStringLength(
    'sourceUri',
    sourceUri,
    0,
    2048,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'SageMaker.ListContexts'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      if (contextType != null) 'ContextType': contextType,
      if (createdAfter != null)
        'CreatedAfter': unixTimestampToJson(createdAfter),
      if (createdBefore != null)
        'CreatedBefore': unixTimestampToJson(createdBefore),
      if (maxResults != null) 'MaxResults': maxResults,
      if (nextToken != null) 'NextToken': nextToken,
      if (sortBy != null) 'SortBy': sortBy.toValue(),
      if (sortOrder != null) 'SortOrder': sortOrder.toValue(),
      if (sourceUri != null) 'SourceUri': sourceUri,
    },
  );

  return ListContextsResponse.fromJson(jsonResponse.body);
}