listJobs method
Lists jobs in a specified category. You can filter results by creation
time, last modified time, name, and status. Results are sorted by the
field you specify in SortBy. Use pagination to retrieve large
result sets efficiently.
The following operations are related to ListJobs:
-
CreateJob -
DescribeJob
Parameter jobCategory :
The category of jobs to list.
Parameter creationTimeAfter :
A filter that returns only jobs created after the specified time.
Parameter creationTimeBefore :
A filter that returns only jobs created before the specified time.
Parameter lastModifiedTimeAfter :
A filter that returns only jobs modified after the specified time.
Parameter lastModifiedTimeBefore :
A filter that returns only jobs modified before the specified time.
Parameter maxResults :
The maximum number of jobs to return in the response. The default value is
50.
Parameter nameContains :
A string in the job name to filter results. Only jobs whose name contains
the specified string are returned.
Parameter nextToken :
If the previous response was truncated, this token retrieves the next set
of results.
Parameter sortBy :
The field to sort results by.
Parameter sortOrder :
The sort order for results. Valid values are Ascending and
Descending.
Parameter statusEquals :
A filter that returns only jobs with the specified status.
Implementation
Future<ListJobsResponse> listJobs({
required JobCategory jobCategory,
DateTime? creationTimeAfter,
DateTime? creationTimeBefore,
DateTime? lastModifiedTimeAfter,
DateTime? lastModifiedTimeBefore,
int? maxResults,
String? nameContains,
String? nextToken,
SortBy? sortBy,
SortOrder? sortOrder,
JobStatus? statusEquals,
}) async {
_s.validateNumRange(
'maxResults',
maxResults,
1,
100,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'SageMaker.ListJobs'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'JobCategory': jobCategory.value,
if (creationTimeAfter != null)
'CreationTimeAfter': unixTimestampToJson(creationTimeAfter),
if (creationTimeBefore != null)
'CreationTimeBefore': unixTimestampToJson(creationTimeBefore),
if (lastModifiedTimeAfter != null)
'LastModifiedTimeAfter': unixTimestampToJson(lastModifiedTimeAfter),
if (lastModifiedTimeBefore != null)
'LastModifiedTimeBefore': unixTimestampToJson(lastModifiedTimeBefore),
if (maxResults != null) 'MaxResults': maxResults,
if (nameContains != null) 'NameContains': nameContains,
if (nextToken != null) 'NextToken': nextToken,
if (sortBy != null) 'SortBy': sortBy.value,
if (sortOrder != null) 'SortOrder': sortOrder.value,
if (statusEquals != null) 'StatusEquals': statusEquals.value,
},
);
return ListJobsResponse.fromJson(jsonResponse.body);
}