@@ -57,35 +57,53 @@ func (c *ModelCatalogServiceAPIController) Routes() Routes {
5757 "/api/model_catalog/v1alpha1/models" ,
5858 c .FindModels ,
5959 },
60+ "FindModelsFilterOptions" : Route {
61+ strings .ToUpper ("Get" ),
62+ "/api/model_catalog/v1alpha1/models/filter_options" ,
63+ c .FindModelsFilterOptions ,
64+ },
6065 "FindSources" : Route {
6166 strings .ToUpper ("Get" ),
6267 "/api/model_catalog/v1alpha1/sources" ,
6368 c .FindSources ,
6469 },
65- "GetModel" : Route {
66- strings .ToUpper ("Get" ),
67- "/api/model_catalog/v1alpha1/sources/{source_id}/models/*" ,
68- c .GetModel ,
69- },
7070 "GetAllModelArtifacts" : Route {
7171 strings .ToUpper ("Get" ),
7272 "/api/model_catalog/v1alpha1/sources/{source_id}/models/{model_name}/artifacts" ,
7373 c .GetAllModelArtifacts ,
7474 },
75+ "GetModel" : Route {
76+ strings .ToUpper ("Get" ),
77+ "/api/model_catalog/v1alpha1/sources/{source_id}/models/{model_name+}" ,
78+ c .GetModel ,
79+ },
7580 }
7681}
7782
7883// FindModels - Search catalog models across sources.
7984func (c * ModelCatalogServiceAPIController ) FindModels (w http.ResponseWriter , r * http.Request ) {
8085 query := r .URL .Query ()
8186 sourceParam := strings .Split (query .Get ("source" ), "," )
87+ sourceLabelParam := query .Get ("sourceLabel" )
8288 qParam := query .Get ("q" )
83- filterQueryParam := query .Get ("filterQuery" )
8489 pageSizeParam := query .Get ("pageSize" )
8590 orderByParam := query .Get ("orderBy" )
8691 sortOrderParam := query .Get ("sortOrder" )
8792 nextPageTokenParam := query .Get ("nextPageToken" )
88- result , err := c .service .FindModels (r .Context (), sourceParam , qParam , filterQueryParam , pageSizeParam , model .OrderByField (orderByParam ), model .SortOrder (sortOrderParam ), nextPageTokenParam )
93+ filterQueryParam := query .Get ("filterQuery" )
94+ result , err := c .service .FindModels (r .Context (), sourceParam , sourceLabelParam , qParam , pageSizeParam , model .OrderByField (orderByParam ), model .SortOrder (sortOrderParam ), nextPageTokenParam , filterQueryParam )
95+ // If an error occurred, encode the error with the status code
96+ if err != nil {
97+ c .errorHandler (w , r , err , & result )
98+ return
99+ }
100+ // If no error, encode the body and the result code
101+ EncodeJSONResponse (result .Body , & result .Code , w )
102+ }
103+
104+ // FindModelsFilterOptions - Lists fields and available options that can be used in `filterQuery` on the list models endpoint.
105+ func (c * ModelCatalogServiceAPIController ) FindModelsFilterOptions (w http.ResponseWriter , r * http.Request ) {
106+ result , err := c .service .FindModelsFilterOptions (r .Context ())
89107 // If an error occurred, encode the error with the status code
90108 if err != nil {
91109 c .errorHandler (w , r , err , & result )
@@ -113,6 +131,26 @@ func (c *ModelCatalogServiceAPIController) FindSources(w http.ResponseWriter, r
113131 EncodeJSONResponse (result .Body , & result .Code , w )
114132}
115133
134+ // GetAllModelArtifacts - List CatalogArtifacts.
135+ func (c * ModelCatalogServiceAPIController ) GetAllModelArtifacts (w http.ResponseWriter , r * http.Request ) {
136+ query := r .URL .Query ()
137+ sourceIdParam := chi .URLParam (r , "source_id" )
138+ modelNameParam := chi .URLParam (r , "model_name" )
139+ pageSizeParam := query .Get ("pageSize" )
140+ orderByParam := query .Get ("orderBy" )
141+ sortOrderParam := query .Get ("sortOrder" )
142+ nextPageTokenParam := query .Get ("nextPageToken" )
143+ artifactTypeParam := query .Get ("artifactType" )
144+ result , err := c .service .GetAllModelArtifacts (r .Context (), sourceIdParam , modelNameParam , pageSizeParam , model .OrderByField (orderByParam ), model .SortOrder (sortOrderParam ), nextPageTokenParam , artifactTypeParam )
145+ // If an error occurred, encode the error with the status code
146+ if err != nil {
147+ c .errorHandler (w , r , err , & result )
148+ return
149+ }
150+ // If no error, encode the body and the result code
151+ EncodeJSONResponse (result .Body , & result .Code , w )
152+ }
153+
116154// GetModel - Get a `CatalogModel`.
117155func (c * ModelCatalogServiceAPIController ) GetModel (w http.ResponseWriter , r * http.Request ) {
118156 sourceIdParam := chi .URLParam (r , "source_id" )
@@ -141,23 +179,3 @@ func (c *ModelCatalogServiceAPIController) GetModel(w http.ResponseWriter, r *ht
141179 // If no error, encode the body and the result code
142180 EncodeJSONResponse (result .Body , & result .Code , w )
143181}
144-
145- // GetAllModelArtifacts - List CatalogArtifacts.
146- func (c * ModelCatalogServiceAPIController ) GetAllModelArtifacts (w http.ResponseWriter , r * http.Request ) {
147- query := r .URL .Query ()
148- sourceIdParam := chi .URLParam (r , "source_id" )
149- modelNameParam := chi .URLParam (r , "model_name" )
150- artifactTypeParam := query .Get ("artifact_type" )
151- pageSizeParam := query .Get ("pageSize" )
152- orderByParam := query .Get ("orderBy" )
153- sortOrderParam := query .Get ("sortOrder" )
154- nextPageTokenParam := query .Get ("nextPageToken" )
155- result , err := c .service .GetAllModelArtifacts (r .Context (), sourceIdParam , modelNameParam , artifactTypeParam , pageSizeParam , model .OrderByField (orderByParam ), model .SortOrder (sortOrderParam ), nextPageTokenParam )
156- // If an error occurred, encode the error with the status code
157- if err != nil {
158- c .errorHandler (w , r , err , & result )
159- return
160- }
161- // If no error, encode the body and the result code
162- EncodeJSONResponse (result .Body , & result .Code , w )
163- }
0 commit comments