Filtering, Paging, and Sorting
Filtering, Paging, and Sorting API Queries with Modzy's Golang SDK
Filtering
The Golang SDK implements Modzy's API filters, which allow you to specify any filters you'd like to apply to the results that are returned. This might include filtering a list of models returned by author name or by the model's description. The .WithFilter()
, .WithFilterAnd()
, and .WithFilterOr()
functions can be added to supported functions using a dot notation-style that will dictate to Modzy's API how you'd like your results filtered.
Examples
//Return only open source models
listModelsInput = (&modzy.ListModelsInput{}).WithFilter(modzy.ListModelsFilterFieldAuthor, "Open Source")
//Return only active models after pagination has been applied
listModelsInput = (&modzy.ListModelsInput{}).WithPaging(1000, 0).WithFilterAnd(modzy.ListModelsFilterFieldIsActive, "true")
//Return only models that process "Image" data types after pagination has been applied
listModelsInput = (&modzy.ListModelsInput{}).WithPaging(5, 0).WithFilterAnd(modzy.ListModelsFilterFieldName, "Image")
// Combined search:
listModelsInput = (&modzy.ListModelsInput{}).WithPaging(1000, 0).
WithFilterAnd(modzy.ListModelsFilterFieldName, "Image").
WithFilterAnd(modzy.ListModelsFilterFieldAuthor, "Open Source").
WithFilterAnd(modzy.ListModelsFilterFieldIsActive, "true")
Functions that support filtering
Filters can be applied to the following functions:
Filter Field | Equivalent API Filter Field | Example Value |
---|---|---|
ListAccountingUsersFilterFieldFirstName | "firstName" | "Sarah" |
ListAccountingUsersFilterFieldLastName | "lastName" | "Connor" |
ListAccountingUsersFilterFieldEmail | "email" | "[email protected]" |
ListAccountingUsersFilterFieldSearch | "search" | "Sarah Connor" |
ListAccountingUsersFilterFieldStatus | "status" | "Active" |
ListAccountingUsersFilterFieldAccessKey | "accessKey" | "syXs1jd1hQY1FdMTnCjM" |
ListAccountingUsersFilterFieldStartDate | "startDate" | "2021-02-18" |
ListAccountingUsersFilterFieldStartDate | "endDate" | "2022-07-04" |
ListAccountingUsersFilterFieldStartDate | "searchDate" | "updatedAt" |
Learn more about available filter values at List users
Filter Field | Equivalent API Filter Field | Example Value |
---|---|---|
ListJobsHistoryFilterFieldStartDate | "startDate" | "2021-12-29" |
ListJobsHistoryFilterFieldEndDate | "endDate" | "2021-12-30" |
ListJobsHistoryFilterFieldStatus | "status" | "COMPLETED" |
ListJobsHistoryFilterFieldModel | "model" | "Sentiment Analysis" |
ListJobsHistoryFilterFieldUser | "user" | "[email protected]" |
ListJobsHistoryFilterFieldAccessKey | "accessKey" | "syXs1jd1hQY1FdMTnCjM" |
Learn more about available filter values at List the job history
Filter Field | Equivalent API Filter Field | Example Value |
---|---|---|
ListModelsFilterFieldModelID | "modelId" | "aevbu1h3yw" |
ListModelsFilterFieldAuthor | "author" | "Open Source" |
ListModelsFilterFieldCreatedByEmail | "createdByEmail" | "[email protected]" |
ListModelsFilterFieldName | "name" | "Sarah Connor" |
ListModelsFilterFieldDescription | "description" | "image-based geolocation" |
ListModelsFilterFieldIsActive | "isActive" | "syXs1jd1hQY1FdMTnCjM" |
ListModelsFilterFieldIsExpired | "isExpired" | "FALSE" |
ListModelsFilterFieldIsCommercial | "isCommercial" | "TRUE" |
ListModelsFilterFieldIsRecommended | "isRecommended" | "FALSE" |
ListModelsFilterFieldLastActiveDateTime | "lastActiveDateTime" | "2021-12-18" |
Learn more about available filter values at List models
Filter Field | Equivalent API Filter Field | Example Value |
---|---|---|
ListModelVersionsFilterFieldVersion | "version" | "0.0.1" |
ListModelVersionsFilterFieldCreatedAt | "createdAt" | "2021-12-30" |
ListModelVersionsFilterFieldCreatedBy | "createdBy" | "2020-12-22" |
ListModelVersionsFilterFieldStatus | "status" | "active" |
ListModelVersionsFilterFieldIsAvailable | "isAvailable" | "TRUE" |
ListModelVersionsFilterFieldIsUpdateAt | "updatedAt" | "2021-02-12" |
ListModelVersionsFilterFieldIsActive | "isActive" | "TRUE" |
ListModelVersionsFilterFieldIsExperimental | "isExperimental" | "FALSE" |
Learn more about available filter values at List versions
Filter Field | Equivalent API Filter Field | Example Value |
---|---|---|
ListProjectsFilterFieldSearch | "search" | "sentiment scoring" |
ListProjectsFilterFieldStatus | "status" | "active" |
Learn more about available filter values at List projects
Filtering with boolean logic
.WithFilter()
Applies a filter to your API query, by adding this function to the end of a supported function
.WithFilterAnd()
Applies a filter to your API query after other filter or pagination functions have already been applied using AND boolean logic
.WithFilterOr()
Applies a filter to your API query after other filter or pagination functions have already been applied using OR boolean logic
Pagination
The Golang SDK also implements Modzy's API pagination, allowing you to specify the number of results you'd like to receive per page and the number of pages that you'd like returned. .WithPaging(perPage int, page int)
can be added to supported functions using a dot notation style that will dictate to Modzy's API how you'd like your results paginated.
Examples
//Return 1000 models per page, but only return the first page
listModelsInput = (&modzy.ListModelsInput{}).WithPaging(1000, 0)
//Return 5 models per page, but only return 5 pages (4 with a zero index)
listModelsInput = (&modzy.ListModelsInput{}).WithPaging(5, 4)
Functions that support pagination
Pagination can be applied to the following functions:
- ListAccountingUsersInput
- ListJobsHistoryInput
- ListModelsInput
- ListModelVersionsInput
- ListProjectsInput
Sorting
Updated over 1 year ago