Skip to content

Commit fbbc35a

Browse files
committed
feat: add filter options and fix openapi spec conflicts
Signed-off-by: Sidney Glinton <[email protected]>
1 parent f48585b commit fbbc35a

File tree

4 files changed

+152
-23
lines changed

4 files changed

+152
-23
lines changed

api/openapi/catalog.yaml

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ paths:
3232
explode: true
3333
in: query
3434
required: false
35+
- name: sourceLabel
36+
description: |-
37+
Filter models by the label associated with the source. This
38+
parameter may be included multiple times to include models from
39+
multiple sources.
40+
schema:
41+
type: string
42+
in: query
43+
required: false
3544
- name: q
3645
description: Free-form keyword search used to filter the response.
3746
schema:
@@ -55,6 +64,22 @@ paths:
5564
"500":
5665
$ref: "#/components/responses/InternalServerError"
5766
operationId: findModels
67+
/api/model_catalog/v1alpha1/models/filter_options:
68+
description: Lists options for `filterQuery` when listing models.
69+
get:
70+
summary: Lists fields and available options that can be used in `filterQuery` on the list models endpoint.
71+
tags:
72+
- ModelCatalogService
73+
responses:
74+
"200":
75+
$ref: "#/components/responses/FilterOptionsResponse"
76+
"400":
77+
$ref: "#/components/responses/BadRequest"
78+
"401":
79+
$ref: "#/components/responses/Unauthorized"
80+
"500":
81+
$ref: "#/components/responses/InternalServerError"
82+
operationId: findModelsFilterOptions
5883
/api/model_catalog/v1alpha1/sources:
5984
summary: Path used to get the list of catalog sources.
6085
description: >-
@@ -142,16 +167,11 @@ paths:
142167
type: string
143168
in: path
144169
required: true
145-
- name: artifact_type
146-
description: Filter artifacts by type.
147-
schema:
148-
type: string
149-
in: query
150-
required: false
151170
- $ref: "#/components/parameters/pageSize"
152171
- $ref: "#/components/parameters/orderBy"
153172
- $ref: "#/components/parameters/sortOrder"
154173
- $ref: "#/components/parameters/nextPageToken"
174+
- $ref: "#/components/parameters/catalogArtifactType"
155175
components:
156176
schemas:
157177
ArtifactTypeQueryParam:
@@ -422,6 +442,38 @@ components:
422442
message:
423443
description: Error message
424444
type: string
445+
FilterOption:
446+
type: object
447+
required:
448+
- type
449+
properties:
450+
type:
451+
type: string
452+
description: The data type of the filter option
453+
enum:
454+
- string
455+
- number
456+
values:
457+
type: array
458+
description: Known values of the property for string types with a small number of possible options.
459+
items: {}
460+
range:
461+
type: object
462+
description: Min and max values for number types.
463+
properties:
464+
min:
465+
type: number
466+
max:
467+
type: number
468+
FilterOptionsList:
469+
description: List of FilterOptions
470+
type: object
471+
properties:
472+
filters:
473+
type: object
474+
description: A single filter option.
475+
additionalProperties:
476+
$ref: "#/components/schemas/FilterOption"
425477
MetadataBoolValue:
426478
description: A bool property value.
427479
type: object
@@ -586,6 +638,12 @@ components:
586638
schema:
587639
$ref: "#/components/schemas/Error"
588640
description: Conflict with current state of target resource
641+
FilterOptionsResponse:
642+
content:
643+
application/json:
644+
schema:
645+
$ref: "#/components/schemas/FilterOptionsList"
646+
description: A response containing options for a `filterQuery` parameter.
589647
InternalServerError:
590648
content:
591649
application/json:
@@ -629,6 +687,18 @@ components:
629687
$ref: "#/components/schemas/OrderByField"
630688
in: query
631689
required: false
690+
catalogArtifactType:
691+
name: artifactType
692+
description: |-
693+
Specifies the artifact types to return. May be specified multiple
694+
times to retrieve multiple artifact types.
695+
schema:
696+
type: string
697+
enum:
698+
- model-artifact
699+
- metrics-artifact
700+
in: query
701+
required: false
632702
id:
633703
name: id
634704
description: The ID of resource.

api/openapi/src/catalog.yaml

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ paths:
3232
explode: true
3333
in: query
3434
required: false
35+
- name: sourceLabel
36+
description: |-
37+
Filter models by the label associated with the source. This
38+
parameter may be included multiple times to include models from
39+
multiple sources.
40+
schema:
41+
type: string
42+
in: query
43+
required: false
3544
- name: q
3645
description: Free-form keyword search used to filter the response.
3746
schema:
@@ -55,6 +64,22 @@ paths:
5564
"500":
5665
$ref: "#/components/responses/InternalServerError"
5766
operationId: findModels
67+
/api/model_catalog/v1alpha1/models/filter_options:
68+
description: Lists options for `filterQuery` when listing models.
69+
get:
70+
summary: Lists fields and available options that can be used in `filterQuery` on the list models endpoint.
71+
tags:
72+
- ModelCatalogService
73+
responses:
74+
"200":
75+
$ref: "#/components/responses/FilterOptionsResponse"
76+
"400":
77+
$ref: "#/components/responses/BadRequest"
78+
"401":
79+
$ref: "#/components/responses/Unauthorized"
80+
"500":
81+
$ref: "#/components/responses/InternalServerError"
82+
operationId: findModelsFilterOptions
5883
/api/model_catalog/v1alpha1/sources:
5984
summary: Path used to get the list of catalog sources.
6085
description: >-
@@ -142,16 +167,11 @@ paths:
142167
type: string
143168
in: path
144169
required: true
145-
- name: artifact_type
146-
description: Filter artifacts by type.
147-
schema:
148-
type: string
149-
in: query
150-
required: false
151170
- $ref: "#/components/parameters/pageSize"
152171
- $ref: "#/components/parameters/orderBy"
153172
- $ref: "#/components/parameters/sortOrder"
154173
- $ref: "#/components/parameters/nextPageToken"
174+
- $ref: "#/components/parameters/catalogArtifactType"
155175
components:
156176
schemas:
157177
CatalogArtifact:
@@ -283,6 +303,38 @@ components:
283303
items:
284304
$ref: "#/components/schemas/CatalogSource"
285305
- $ref: "#/components/schemas/BaseResourceList"
306+
FilterOption:
307+
type: object
308+
required:
309+
- type
310+
properties:
311+
type:
312+
type: string
313+
description: The data type of the filter option
314+
enum:
315+
- string
316+
- number
317+
values:
318+
type: array
319+
description: Known values of the property for string types with a small number of possible options.
320+
items: {}
321+
range:
322+
type: object
323+
description: Min and max values for number types.
324+
properties:
325+
min:
326+
type: number
327+
max:
328+
type: number
329+
FilterOptionsList:
330+
description: List of FilterOptions
331+
type: object
332+
properties:
333+
filters:
334+
type: object
335+
description: A single filter option.
336+
additionalProperties:
337+
$ref: "#/components/schemas/FilterOption"
286338
OrderByField:
287339
description: Supported fields for ordering result entities.
288340
enum:
@@ -323,6 +375,12 @@ components:
323375
schema:
324376
$ref: "#/components/schemas/CatalogSource"
325377
description: A response containing a `CatalogSource` entity.
378+
FilterOptionsResponse:
379+
content:
380+
application/json:
381+
schema:
382+
$ref: "#/components/schemas/FilterOptionsList"
383+
description: A response containing options for a `filterQuery` parameter.
326384

327385
parameters:
328386
orderBy:
@@ -337,4 +395,16 @@ components:
337395
$ref: "#/components/schemas/OrderByField"
338396
in: query
339397
required: false
398+
catalogArtifactType:
399+
name: artifactType
400+
description: |-
401+
Specifies the artifact types to return. May be specified multiple
402+
times to retrieve multiple artifact types.
403+
schema:
404+
type: string
405+
enum:
406+
- model-artifact
407+
- metrics-artifact
408+
in: query
409+
required: false
340410
tags: []

catalog/internal/server/openapi/api_model_catalog_service_service_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,6 @@ func TestGetAllModelArtifacts(t *testing.T) {
979979
context.Background(),
980980
tc.sourceID,
981981
tc.modelName,
982-
"",
983982
"10",
984983
model.ORDERBYFIELD_CREATE_TIME,
985984
model.SORTORDER_ASC,

catalog/pkg/openapi/api_model_catalog_service.go

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)