From c996a0eb9701536eb902f7a5d1ef453532b8a393 Mon Sep 17 00:00:00 2001 From: Isabella do Amaral Date: Thu, 19 Sep 2024 21:03:33 -0300 Subject: [PATCH 1/3] OAS: add generic artifacts routes Signed-off-by: Isabella do Amaral --- api/openapi/model-registry.yaml | 215 ++- clients/python/src/.openapi-generator/FILES | 4 + .../src/model_registry/types/artifacts.py | 2 + clients/python/src/mr_openapi/README.md | 20 +- clients/python/src/mr_openapi/__init__.py | 4 + .../api/model_registry_service_api.py | 1504 +++++++++++++++-- .../python/src/mr_openapi/models/__init__.py | 4 + .../src/mr_openapi/models/artifact_create.py | 174 ++ .../src/mr_openapi/models/artifact_update.py | 174 ++ .../src/mr_openapi/models/doc_artifact.py | 4 +- .../mr_openapi/models/doc_artifact_create.py | 128 ++ .../mr_openapi/models/doc_artifact_update.py | 122 ++ .../src/mr_openapi/models/model_artifact.py | 4 +- .../models/model_artifact_create.py | 3 + .../models/model_artifact_update.py | 5 +- .../src/mr_openapi/models/registered_model.py | 2 +- .../models/registered_model_create.py | 2 +- .../generated/mlmd_openapi_converter.gen.go | 36 +- .../generated/openapi_converter.gen.go | 129 +- .../generated/openapi_reconciler.gen.go | 150 ++ internal/converter/openapi_converter.go | 20 + internal/converter/openapi_converter_test.go | 5 +- internal/converter/openapi_converter_util.go | 3 +- internal/converter/openapi_reconciler.go | 5 + internal/server/openapi/api.go | 5 + .../openapi/api_model_registry_service.go | 126 ++ .../api_model_registry_service_service.go | 76 + internal/server/openapi/type_asserts.go | 103 ++ patches/type_asserts.patch | 69 + pkg/api/api.go | 2 + pkg/core/artifact.go | 45 + pkg/core/artifact_test.go | 53 + pkg/openapi/.openapi-generator/FILES | 4 + pkg/openapi/api_model_registry_service.go | 1039 ++++++++++-- pkg/openapi/model_artifact_create.go | 163 ++ pkg/openapi/model_artifact_update.go | 163 ++ pkg/openapi/model_doc_artifact.go | 57 +- pkg/openapi/model_doc_artifact_create.go | 342 ++++ pkg/openapi/model_doc_artifact_update.go | 305 ++++ pkg/openapi/model_model_artifact.go | 57 +- pkg/openapi/model_model_artifact_create.go | 33 +- pkg/openapi/model_model_artifact_update.go | 37 +- pkg/openapi/model_registered_model.go | 2 +- pkg/openapi/model_registered_model_create.go | 2 +- 44 files changed, 5042 insertions(+), 360 deletions(-) create mode 100644 clients/python/src/mr_openapi/models/artifact_create.py create mode 100644 clients/python/src/mr_openapi/models/artifact_update.py create mode 100644 clients/python/src/mr_openapi/models/doc_artifact_create.py create mode 100644 clients/python/src/mr_openapi/models/doc_artifact_update.py create mode 100644 pkg/openapi/model_artifact_create.go create mode 100644 pkg/openapi/model_artifact_update.go create mode 100644 pkg/openapi/model_doc_artifact_create.go create mode 100644 pkg/openapi/model_doc_artifact_update.go diff --git a/api/openapi/model-registry.yaml b/api/openapi/model-registry.yaml index 392cf116..a18984c1 100644 --- a/api/openapi/model-registry.yaml +++ b/api/openapi/model-registry.yaml @@ -10,6 +10,129 @@ servers: - url: "https://localhost:8080" - url: "http://localhost:8080" paths: + /api/model_registry/v1alpha3/artifact: + summary: Path used to search for an artifact. + description: >- + The REST endpoint/path used to search for an `Artifact` entity. This path contains a `GET` operation to perform the find task. + get: + tags: + - ModelRegistryService + responses: + "200": + $ref: "#/components/responses/ArtifactResponse" + "400": + $ref: "#/components/responses/BadRequest" + "401": + $ref: "#/components/responses/Unauthorized" + "404": + $ref: "#/components/responses/NotFound" + "500": + $ref: "#/components/responses/InternalServerError" + operationId: findArtifact + summary: Get an Artifact that matches search parameters. + description: Gets the details of a single instance of an `Artifact` that matches search parameters. + parameters: + - $ref: "#/components/parameters/name" + - $ref: "#/components/parameters/externalId" + - $ref: "#/components/parameters/parentResourceId" + /api/model_registry/v1alpha3/artifacts: + summary: Path used to manage the list of artifacts. + description: >- + The REST endpoint/path used to list and create zero or more `Artifact` entities. This path contains a `GET` and `POST` operation to perform the list and create tasks, respectively. + get: + tags: + - ModelRegistryService + parameters: + - $ref: "#/components/parameters/pageSize" + - $ref: "#/components/parameters/orderBy" + - $ref: "#/components/parameters/sortOrder" + - $ref: "#/components/parameters/nextPageToken" + responses: + "200": + $ref: "#/components/responses/ArtifactListResponse" + "400": + $ref: "#/components/responses/BadRequest" + "401": + $ref: "#/components/responses/Unauthorized" + "404": + $ref: "#/components/responses/NotFound" + "500": + $ref: "#/components/responses/InternalServerError" + operationId: getArtifacts + summary: List All Artifacts + description: Gets a list of all `Artifact` entities. + post: + requestBody: + description: A new `Artifact` to be created. + content: + application/json: + schema: + $ref: "#/components/schemas/ArtifactCreate" + required: true + tags: + - ModelRegistryService + responses: + "201": + $ref: "#/components/responses/ArtifactResponse" + "400": + $ref: "#/components/responses/BadRequest" + "401": + $ref: "#/components/responses/Unauthorized" + "500": + $ref: "#/components/responses/InternalServerError" + operationId: createArtifact + summary: Create an Artifact + description: Creates a new instance of an `Artifact`. + /api/model_registry/v1alpha3/artifacts/{id}: + summary: Path used to manage a single Artifact. + description: >- + The REST endpoint/path used to get and update single instances of an `Artifact`. This path contains `GET` and `PATCH` operations used to perform the get and update tasks, respectively. + get: + tags: + - ModelRegistryService + responses: + "200": + $ref: "#/components/responses/ArtifactResponse" + "401": + $ref: "#/components/responses/Unauthorized" + "404": + $ref: "#/components/responses/NotFound" + "500": + $ref: "#/components/responses/InternalServerError" + operationId: getArtifact + summary: Get an Artifact + description: Gets the details of a single instance of an `Artifact`. + patch: + requestBody: + description: Updated `Artifact` information. + content: + application/json: + schema: + $ref: "#/components/schemas/ArtifactUpdate" + required: true + tags: + - ModelRegistryService + responses: + "200": + $ref: "#/components/responses/ArtifactResponse" + "400": + $ref: "#/components/responses/BadRequest" + "401": + $ref: "#/components/responses/Unauthorized" + "404": + $ref: "#/components/responses/NotFound" + "500": + $ref: "#/components/responses/InternalServerError" + operationId: updateArtifact + summary: Update an Artifact + description: Updates an existing `Artifact`. + parameters: + - name: id + description: A unique identifier for an `Artifact`. + schema: + type: string + in: path + required: true /api/model_registry/v1alpha3/model_artifact: summary: Path used to search for a modelartifact. description: >- @@ -970,36 +1093,37 @@ components: type: string ModelArtifact: description: An ML model artifact. - type: object - required: - - artifactType - properties: - artifactType: - type: string - default: "model-artifact" allOf: - $ref: "#/components/schemas/BaseArtifact" - $ref: "#/components/schemas/ModelArtifactCreate" DocArtifact: description: A document. - type: object + allOf: + - $ref: "#/components/schemas/BaseArtifact" + - $ref: "#/components/schemas/DocArtifactCreate" + DocArtifactCreate: + description: A document artifact to be created. + allOf: + - $ref: "#/components/schemas/BaseArtifactCreate" + - $ref: "#/components/schemas/DocArtifactUpdate" + DocArtifactUpdate: + description: A document artifact to be updated. required: - artifactType - properties: - artifactType: - type: string - default: "doc-artifact" allOf: - - $ref: "#/components/schemas/BaseArtifact" + - $ref: "#/components/schemas/BaseArtifactUpdate" + - type: object + properties: + artifactType: + type: string + default: "doc-artifact" RegisteredModel: description: A registered model in model registry. A registered model has ModelVersion children. allOf: - $ref: "#/components/schemas/BaseResource" - - type: object - $ref: "#/components/schemas/RegisteredModelCreate" ModelVersionList: description: List of ModelVersion entities. - type: object allOf: - type: object properties: @@ -1011,7 +1135,6 @@ components: - $ref: "#/components/schemas/BaseResourceList" ModelArtifactList: description: List of ModelArtifact entities. - type: object allOf: - type: object properties: @@ -1026,9 +1149,9 @@ components: required: - name allOf: - - type: object - $ref: "#/components/schemas/BaseResourceCreate" - $ref: "#/components/schemas/RegisteredModelUpdate" + - type: object properties: name: description: |- @@ -1098,12 +1221,10 @@ components: BaseExecution: allOf: - $ref: "#/components/schemas/BaseExecutionCreate" - - type: object - $ref: "#/components/schemas/BaseResource" BaseExecutionCreate: allOf: - $ref: "#/components/schemas/BaseExecutionUpdate" - - type: object - $ref: "#/components/schemas/BaseResourceCreate" BaseExecutionUpdate: type: object @@ -1286,7 +1407,6 @@ components: type: integer ArtifactList: description: A list of Artifact entities. - type: object allOf: - type: object properties: @@ -1297,11 +1417,16 @@ components: $ref: "#/components/schemas/Artifact" - $ref: "#/components/schemas/BaseResourceList" ModelArtifactUpdate: - description: An ML model artifact. + description: An ML model artifact to be updated. + required: + - artifactType allOf: - $ref: "#/components/schemas/BaseArtifactUpdate" - type: object properties: + artifactType: + type: string + default: "model-artifact" modelFormatName: description: Name of the model format. type: string @@ -1319,10 +1444,16 @@ components: type: string ModelArtifactCreate: description: An ML model artifact. - type: object + required: + - artifactType allOf: - $ref: "#/components/schemas/BaseArtifactCreate" - $ref: "#/components/schemas/ModelArtifactUpdate" + - type: object + properties: + artifactType: + type: string + default: "model-artifact" Error: description: Error code and message. required: @@ -1363,9 +1494,28 @@ components: allOf: - $ref: "#/components/schemas/BaseArtifactCreate" - $ref: "#/components/schemas/BaseResource" + ArtifactCreate: + description: An Artifact to be created. + oneOf: + - $ref: "#/components/schemas/ModelArtifactCreate" + - $ref: "#/components/schemas/DocArtifactCreate" + discriminator: + propertyName: artifactType + mapping: + model-artifact: "#/components/schemas/ModelArtifactCreate" + doc-artifact: "#/components/schemas/DocArtifactCreate" + ArtifactUpdate: + description: An Artifact to be updated. + oneOf: + - $ref: "#/components/schemas/ModelArtifactUpdate" + - $ref: "#/components/schemas/DocArtifactUpdate" + discriminator: + propertyName: artifactType + mapping: + model-artifact: "#/components/schemas/ModelArtifactUpdate" + doc-artifact: "#/components/schemas/DocArtifactUpdate" ServingEnvironmentList: description: List of ServingEnvironments. - type: object allOf: - type: object properties: @@ -1378,7 +1528,6 @@ components: - $ref: "#/components/schemas/BaseResourceList" RegisteredModelList: description: List of RegisteredModels. - type: object allOf: - type: object properties: @@ -1402,7 +1551,6 @@ components: ServingEnvironmentCreate: description: A Model Serving environment for serving `RegisteredModels`. allOf: - - type: object - $ref: "#/components/schemas/BaseResourceCreate" - $ref: "#/components/schemas/ServingEnvironmentUpdate" InferenceService: @@ -1413,7 +1561,6 @@ components: - $ref: "#/components/schemas/InferenceServiceCreate" InferenceServiceList: description: List of InferenceServices. - type: object allOf: - type: object properties: @@ -1426,7 +1573,6 @@ components: - $ref: "#/components/schemas/BaseResourceList" ServeModelList: description: List of ServeModel entities. - type: object allOf: - type: object properties: @@ -1438,7 +1584,6 @@ components: - $ref: "#/components/schemas/BaseResourceList" ServeModel: description: An ML model serving action. - type: object allOf: - $ref: "#/components/schemas/BaseExecution" - $ref: "#/components/schemas/ServeModelCreate" @@ -1448,12 +1593,12 @@ components: - $ref: "#/components/schemas/BaseExecutionUpdate" ServeModelCreate: description: An ML model serving action. + required: + - modelVersionId allOf: - $ref: "#/components/schemas/BaseExecutionCreate" - $ref: "#/components/schemas/ServeModelUpdate" - - required: - - modelVersionId - type: object + - type: object properties: modelVersionId: description: ID of the `ModelVersion` that was served in `InferenceService`. @@ -1477,13 +1622,13 @@ components: InferenceServiceCreate: description: >- An `InferenceService` entity in a `ServingEnvironment` represents a deployed `ModelVersion` from a `RegisteredModel` created by Model Serving. + required: + - registeredModelId + - servingEnvironmentId allOf: - $ref: "#/components/schemas/BaseResourceCreate" - $ref: "#/components/schemas/InferenceServiceUpdate" - - required: - - registeredModelId - - servingEnvironmentId - type: object + - type: object properties: registeredModelId: description: ID of the `RegisteredModel` to serve. diff --git a/clients/python/src/.openapi-generator/FILES b/clients/python/src/.openapi-generator/FILES index 0c6091c8..1d6f28a4 100644 --- a/clients/python/src/.openapi-generator/FILES +++ b/clients/python/src/.openapi-generator/FILES @@ -7,8 +7,10 @@ mr_openapi/configuration.py mr_openapi/exceptions.py mr_openapi/models/__init__.py mr_openapi/models/artifact.py +mr_openapi/models/artifact_create.py mr_openapi/models/artifact_list.py mr_openapi/models/artifact_state.py +mr_openapi/models/artifact_update.py mr_openapi/models/base_artifact.py mr_openapi/models/base_artifact_create.py mr_openapi/models/base_artifact_update.py @@ -20,6 +22,8 @@ mr_openapi/models/base_resource_create.py mr_openapi/models/base_resource_list.py mr_openapi/models/base_resource_update.py mr_openapi/models/doc_artifact.py +mr_openapi/models/doc_artifact_create.py +mr_openapi/models/doc_artifact_update.py mr_openapi/models/error.py mr_openapi/models/execution_state.py mr_openapi/models/inference_service.py diff --git a/clients/python/src/model_registry/types/artifacts.py b/clients/python/src/model_registry/types/artifacts.py index 64f5a974..a8cfd793 100644 --- a/clients/python/src/model_registry/types/artifacts.py +++ b/clients/python/src/model_registry/types/artifacts.py @@ -152,6 +152,7 @@ def create(self, **kwargs) -> ModelArtifactCreate: return ModelArtifactCreate( customProperties=self._map_custom_properties(), **self._props_as_dict(exclude=("id", "custom_properties")), + artifactType="model-artifact", **kwargs, ) @@ -161,6 +162,7 @@ def update(self, **kwargs) -> ModelArtifactUpdate: return ModelArtifactUpdate( customProperties=self._map_custom_properties(), **self._props_as_dict(exclude=("id", "name", "custom_properties")), + artifactType="model-artifact", **kwargs, ) diff --git a/clients/python/src/mr_openapi/README.md b/clients/python/src/mr_openapi/README.md index ffee94f0..c7f687c7 100644 --- a/clients/python/src/mr_openapi/README.md +++ b/clients/python/src/mr_openapi/README.md @@ -55,16 +55,15 @@ configuration = mr_openapi.Configuration( async with mr_openapi.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = mr_openapi.ModelRegistryServiceApi(api_client) - servingenvironment_id = 'servingenvironment_id_example' # str | A unique identifier for a `ServingEnvironment`. - inference_service_create = mr_openapi.InferenceServiceCreate() # InferenceServiceCreate | A new `InferenceService` to be created. + artifact_create = mr_openapi.ArtifactCreate() # ArtifactCreate | A new `Artifact` to be created. try: - # Create a InferenceService in ServingEnvironment - api_response = await api_instance.create_environment_inference_service(servingenvironment_id, inference_service_create) - print("The response of ModelRegistryServiceApi->create_environment_inference_service:\n") + # Create an Artifact + api_response = await api_instance.create_artifact(artifact_create) + print("The response of ModelRegistryServiceApi->create_artifact:\n") pprint(api_response) except ApiException as e: - print("Exception when calling ModelRegistryServiceApi->create_environment_inference_service: %s\n" % e) + print("Exception when calling ModelRegistryServiceApi->create_artifact: %s\n" % e) ``` @@ -74,6 +73,7 @@ All URIs are relative to *https://localhost:8080* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- +*ModelRegistryServiceApi* | [**create_artifact**](mr_openapi/docs/ModelRegistryServiceApi.md#create_artifact) | **POST** /api/model_registry/v1alpha3/artifacts | Create an Artifact *ModelRegistryServiceApi* | [**create_environment_inference_service**](mr_openapi/docs/ModelRegistryServiceApi.md#create_environment_inference_service) | **POST** /api/model_registry/v1alpha3/serving_environments/{servingenvironmentId}/inference_services | Create a InferenceService in ServingEnvironment *ModelRegistryServiceApi* | [**create_inference_service**](mr_openapi/docs/ModelRegistryServiceApi.md#create_inference_service) | **POST** /api/model_registry/v1alpha3/inference_services | Create a InferenceService *ModelRegistryServiceApi* | [**create_inference_service_serve**](mr_openapi/docs/ModelRegistryServiceApi.md#create_inference_service_serve) | **POST** /api/model_registry/v1alpha3/inference_services/{inferenceserviceId}/serves | Create a ServeModel action in a InferenceService @@ -82,11 +82,14 @@ Class | Method | HTTP request | Description *ModelRegistryServiceApi* | [**create_registered_model**](mr_openapi/docs/ModelRegistryServiceApi.md#create_registered_model) | **POST** /api/model_registry/v1alpha3/registered_models | Create a RegisteredModel *ModelRegistryServiceApi* | [**create_registered_model_version**](mr_openapi/docs/ModelRegistryServiceApi.md#create_registered_model_version) | **POST** /api/model_registry/v1alpha3/registered_models/{registeredmodelId}/versions | Create a ModelVersion in RegisteredModel *ModelRegistryServiceApi* | [**create_serving_environment**](mr_openapi/docs/ModelRegistryServiceApi.md#create_serving_environment) | **POST** /api/model_registry/v1alpha3/serving_environments | Create a ServingEnvironment +*ModelRegistryServiceApi* | [**find_artifact**](mr_openapi/docs/ModelRegistryServiceApi.md#find_artifact) | **GET** /api/model_registry/v1alpha3/artifact | Get an Artifact that matches search parameters. *ModelRegistryServiceApi* | [**find_inference_service**](mr_openapi/docs/ModelRegistryServiceApi.md#find_inference_service) | **GET** /api/model_registry/v1alpha3/inference_service | Get an InferenceServices that matches search parameters. *ModelRegistryServiceApi* | [**find_model_artifact**](mr_openapi/docs/ModelRegistryServiceApi.md#find_model_artifact) | **GET** /api/model_registry/v1alpha3/model_artifact | Get a ModelArtifact that matches search parameters. *ModelRegistryServiceApi* | [**find_model_version**](mr_openapi/docs/ModelRegistryServiceApi.md#find_model_version) | **GET** /api/model_registry/v1alpha3/model_version | Get a ModelVersion that matches search parameters. *ModelRegistryServiceApi* | [**find_registered_model**](mr_openapi/docs/ModelRegistryServiceApi.md#find_registered_model) | **GET** /api/model_registry/v1alpha3/registered_model | Get a RegisteredModel that matches search parameters. *ModelRegistryServiceApi* | [**find_serving_environment**](mr_openapi/docs/ModelRegistryServiceApi.md#find_serving_environment) | **GET** /api/model_registry/v1alpha3/serving_environment | Find ServingEnvironment +*ModelRegistryServiceApi* | [**get_artifact**](mr_openapi/docs/ModelRegistryServiceApi.md#get_artifact) | **GET** /api/model_registry/v1alpha3/artifacts/{id} | Get an Artifact +*ModelRegistryServiceApi* | [**get_artifacts**](mr_openapi/docs/ModelRegistryServiceApi.md#get_artifacts) | **GET** /api/model_registry/v1alpha3/artifacts | List All Artifacts *ModelRegistryServiceApi* | [**get_environment_inference_services**](mr_openapi/docs/ModelRegistryServiceApi.md#get_environment_inference_services) | **GET** /api/model_registry/v1alpha3/serving_environments/{servingenvironmentId}/inference_services | List All ServingEnvironment's InferenceServices *ModelRegistryServiceApi* | [**get_inference_service**](mr_openapi/docs/ModelRegistryServiceApi.md#get_inference_service) | **GET** /api/model_registry/v1alpha3/inference_services/{inferenceserviceId} | Get a InferenceService *ModelRegistryServiceApi* | [**get_inference_service_model**](mr_openapi/docs/ModelRegistryServiceApi.md#get_inference_service_model) | **GET** /api/model_registry/v1alpha3/inference_services/{inferenceserviceId}/model | Get InferenceService's RegisteredModel @@ -103,6 +106,7 @@ Class | Method | HTTP request | Description *ModelRegistryServiceApi* | [**get_registered_models**](mr_openapi/docs/ModelRegistryServiceApi.md#get_registered_models) | **GET** /api/model_registry/v1alpha3/registered_models | List All RegisteredModels *ModelRegistryServiceApi* | [**get_serving_environment**](mr_openapi/docs/ModelRegistryServiceApi.md#get_serving_environment) | **GET** /api/model_registry/v1alpha3/serving_environments/{servingenvironmentId} | Get a ServingEnvironment *ModelRegistryServiceApi* | [**get_serving_environments**](mr_openapi/docs/ModelRegistryServiceApi.md#get_serving_environments) | **GET** /api/model_registry/v1alpha3/serving_environments | List All ServingEnvironments +*ModelRegistryServiceApi* | [**update_artifact**](mr_openapi/docs/ModelRegistryServiceApi.md#update_artifact) | **PATCH** /api/model_registry/v1alpha3/artifacts/{id} | Update an Artifact *ModelRegistryServiceApi* | [**update_inference_service**](mr_openapi/docs/ModelRegistryServiceApi.md#update_inference_service) | **PATCH** /api/model_registry/v1alpha3/inference_services/{inferenceserviceId} | Update a InferenceService *ModelRegistryServiceApi* | [**update_model_artifact**](mr_openapi/docs/ModelRegistryServiceApi.md#update_model_artifact) | **PATCH** /api/model_registry/v1alpha3/model_artifacts/{modelartifactId} | Update a ModelArtifact *ModelRegistryServiceApi* | [**update_model_version**](mr_openapi/docs/ModelRegistryServiceApi.md#update_model_version) | **PATCH** /api/model_registry/v1alpha3/model_versions/{modelversionId} | Update a ModelVersion @@ -114,8 +118,10 @@ Class | Method | HTTP request | Description ## Documentation For Models - [Artifact](mr_openapi/docs/Artifact.md) + - [ArtifactCreate](mr_openapi/docs/ArtifactCreate.md) - [ArtifactList](mr_openapi/docs/ArtifactList.md) - [ArtifactState](mr_openapi/docs/ArtifactState.md) + - [ArtifactUpdate](mr_openapi/docs/ArtifactUpdate.md) - [BaseArtifact](mr_openapi/docs/BaseArtifact.md) - [BaseArtifactCreate](mr_openapi/docs/BaseArtifactCreate.md) - [BaseArtifactUpdate](mr_openapi/docs/BaseArtifactUpdate.md) @@ -127,6 +133,8 @@ Class | Method | HTTP request | Description - [BaseResourceList](mr_openapi/docs/BaseResourceList.md) - [BaseResourceUpdate](mr_openapi/docs/BaseResourceUpdate.md) - [DocArtifact](mr_openapi/docs/DocArtifact.md) + - [DocArtifactCreate](mr_openapi/docs/DocArtifactCreate.md) + - [DocArtifactUpdate](mr_openapi/docs/DocArtifactUpdate.md) - [Error](mr_openapi/docs/Error.md) - [ExecutionState](mr_openapi/docs/ExecutionState.md) - [InferenceService](mr_openapi/docs/InferenceService.md) diff --git a/clients/python/src/mr_openapi/__init__.py b/clients/python/src/mr_openapi/__init__.py index 3a01c51d..b022ce3f 100644 --- a/clients/python/src/mr_openapi/__init__.py +++ b/clients/python/src/mr_openapi/__init__.py @@ -32,8 +32,10 @@ # import models into sdk package from mr_openapi.models.artifact import Artifact +from mr_openapi.models.artifact_create import ArtifactCreate from mr_openapi.models.artifact_list import ArtifactList from mr_openapi.models.artifact_state import ArtifactState +from mr_openapi.models.artifact_update import ArtifactUpdate from mr_openapi.models.base_artifact import BaseArtifact from mr_openapi.models.base_artifact_create import BaseArtifactCreate from mr_openapi.models.base_artifact_update import BaseArtifactUpdate @@ -45,6 +47,8 @@ from mr_openapi.models.base_resource_list import BaseResourceList from mr_openapi.models.base_resource_update import BaseResourceUpdate from mr_openapi.models.doc_artifact import DocArtifact +from mr_openapi.models.doc_artifact_create import DocArtifactCreate +from mr_openapi.models.doc_artifact_update import DocArtifactUpdate from mr_openapi.models.error import Error from mr_openapi.models.execution_state import ExecutionState from mr_openapi.models.inference_service import InferenceService diff --git a/clients/python/src/mr_openapi/api/model_registry_service_api.py b/clients/python/src/mr_openapi/api/model_registry_service_api.py index 0e563a10..423c782c 100644 --- a/clients/python/src/mr_openapi/api/model_registry_service_api.py +++ b/clients/python/src/mr_openapi/api/model_registry_service_api.py @@ -15,7 +15,9 @@ from mr_openapi.api_client import ApiClient, RequestSerialized from mr_openapi.api_response import ApiResponse from mr_openapi.models.artifact import Artifact +from mr_openapi.models.artifact_create import ArtifactCreate from mr_openapi.models.artifact_list import ArtifactList +from mr_openapi.models.artifact_update import ArtifactUpdate from mr_openapi.models.inference_service import InferenceService from mr_openapi.models.inference_service_create import InferenceServiceCreate from mr_openapi.models.inference_service_list import InferenceServiceList @@ -56,6 +58,245 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client + @validate_call + async def create_artifact( + self, + artifact_create: Annotated[ArtifactCreate, Field(description="A new `Artifact` to be created.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Artifact: + """Create an Artifact. + + Creates a new instance of an `Artifact`. + + :param artifact_create: A new `Artifact` to be created. (required) + :type artifact_create: ArtifactCreate + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + _param = self._create_artifact_serialize( + artifact_create=artifact_create, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: dict[str, Optional[str]] = { + "201": "Artifact", + "400": "Error", + "401": "Error", + "500": "Error", + } + response_data = await self.api_client.call_api(*_param, _request_timeout=_request_timeout) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + async def create_artifact_with_http_info( + self, + artifact_create: Annotated[ArtifactCreate, Field(description="A new `Artifact` to be created.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Artifact]: + """Create an Artifact. + + Creates a new instance of an `Artifact`. + + :param artifact_create: A new `Artifact` to be created. (required) + :type artifact_create: ArtifactCreate + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + _param = self._create_artifact_serialize( + artifact_create=artifact_create, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: dict[str, Optional[str]] = { + "201": "Artifact", + "400": "Error", + "401": "Error", + "500": "Error", + } + response_data = await self.api_client.call_api(*_param, _request_timeout=_request_timeout) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + async def create_artifact_without_preload_content( + self, + artifact_create: Annotated[ArtifactCreate, Field(description="A new `Artifact` to be created.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Create an Artifact. + + Creates a new instance of an `Artifact`. + + :param artifact_create: A new `Artifact` to be created. (required) + :type artifact_create: ArtifactCreate + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + _param = self._create_artifact_serialize( + artifact_create=artifact_create, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: dict[str, Optional[str]] = { + "201": "Artifact", + "400": "Error", + "401": "Error", + "500": "Error", + } + response_data = await self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _create_artifact_serialize( + self, + artifact_create, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: dict[str, str] = {} + + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, Optional[str]] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if artifact_create is not None: + _body_params = artifact_create + + # set the HTTP header `Accept` + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: list[str] = ["Bearer"] + + return self.api_client.param_serialize( + method="POST", + resource_path="/api/model_registry/v1alpha3/artifacts", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + @validate_call async def create_environment_inference_service( self, @@ -2065,7 +2306,7 @@ def _create_serving_environment_serialize( ) @validate_call - async def find_inference_service( + async def find_artifact( self, name: Annotated[Optional[StrictStr], Field(description="Name of entity to search.")] = None, external_id: Annotated[Optional[StrictStr], Field(description="External ID of entity to search.")] = None, @@ -2081,10 +2322,10 @@ async def find_inference_service( _content_type: Optional[StrictStr] = None, _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> InferenceService: - """Get an InferenceServices that matches search parameters. + ) -> Artifact: + """Get an Artifact that matches search parameters. - Gets the details of a single instance of `InferenceService` that matches search parameters. + Gets the details of a single instance of an `Artifact` that matches search parameters. :param name: Name of entity to search. :type name: str @@ -2113,7 +2354,7 @@ async def find_inference_service( :type _host_index: int, optional :return: Returns the result object. """ # noqa: E501 - _param = self._find_inference_service_serialize( + _param = self._find_artifact_serialize( name=name, external_id=external_id, parent_resource_id=parent_resource_id, @@ -2124,7 +2365,7 @@ async def find_inference_service( ) _response_types_map: dict[str, Optional[str]] = { - "200": "InferenceService", + "200": "Artifact", "400": "Error", "401": "Error", "404": "Error", @@ -2138,7 +2379,7 @@ async def find_inference_service( ).data @validate_call - async def find_inference_service_with_http_info( + async def find_artifact_with_http_info( self, name: Annotated[Optional[StrictStr], Field(description="Name of entity to search.")] = None, external_id: Annotated[Optional[StrictStr], Field(description="External ID of entity to search.")] = None, @@ -2154,10 +2395,10 @@ async def find_inference_service_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[InferenceService]: - """Get an InferenceServices that matches search parameters. + ) -> ApiResponse[Artifact]: + """Get an Artifact that matches search parameters. - Gets the details of a single instance of `InferenceService` that matches search parameters. + Gets the details of a single instance of an `Artifact` that matches search parameters. :param name: Name of entity to search. :type name: str @@ -2186,7 +2427,7 @@ async def find_inference_service_with_http_info( :type _host_index: int, optional :return: Returns the result object. """ # noqa: E501 - _param = self._find_inference_service_serialize( + _param = self._find_artifact_serialize( name=name, external_id=external_id, parent_resource_id=parent_resource_id, @@ -2197,7 +2438,7 @@ async def find_inference_service_with_http_info( ) _response_types_map: dict[str, Optional[str]] = { - "200": "InferenceService", + "200": "Artifact", "400": "Error", "401": "Error", "404": "Error", @@ -2211,7 +2452,7 @@ async def find_inference_service_with_http_info( ) @validate_call - async def find_inference_service_without_preload_content( + async def find_artifact_without_preload_content( self, name: Annotated[Optional[StrictStr], Field(description="Name of entity to search.")] = None, external_id: Annotated[Optional[StrictStr], Field(description="External ID of entity to search.")] = None, @@ -2228,9 +2469,9 @@ async def find_inference_service_without_preload_content( _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Get an InferenceServices that matches search parameters. + """Get an Artifact that matches search parameters. - Gets the details of a single instance of `InferenceService` that matches search parameters. + Gets the details of a single instance of an `Artifact` that matches search parameters. :param name: Name of entity to search. :type name: str @@ -2259,7 +2500,7 @@ async def find_inference_service_without_preload_content( :type _host_index: int, optional :return: Returns the result object. """ # noqa: E501 - _param = self._find_inference_service_serialize( + _param = self._find_artifact_serialize( name=name, external_id=external_id, parent_resource_id=parent_resource_id, @@ -2270,7 +2511,7 @@ async def find_inference_service_without_preload_content( ) _response_types_map: dict[str, Optional[str]] = { - "200": "InferenceService", + "200": "Artifact", "400": "Error", "401": "Error", "404": "Error", @@ -2279,7 +2520,7 @@ async def find_inference_service_without_preload_content( response_data = await self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _find_inference_service_serialize( + def _find_artifact_serialize( self, name, external_id, @@ -2327,7 +2568,7 @@ def _find_inference_service_serialize( return self.api_client.param_serialize( method="GET", - resource_path="/api/model_registry/v1alpha3/inference_service", + resource_path="/api/model_registry/v1alpha3/artifact", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -2341,7 +2582,7 @@ def _find_inference_service_serialize( ) @validate_call - async def find_model_artifact( + async def find_inference_service( self, name: Annotated[Optional[StrictStr], Field(description="Name of entity to search.")] = None, external_id: Annotated[Optional[StrictStr], Field(description="External ID of entity to search.")] = None, @@ -2357,10 +2598,10 @@ async def find_model_artifact( _content_type: Optional[StrictStr] = None, _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ModelArtifact: - """Get a ModelArtifact that matches search parameters. + ) -> InferenceService: + """Get an InferenceServices that matches search parameters. - Gets the details of a single instance of a `ModelArtifact` that matches search parameters. + Gets the details of a single instance of `InferenceService` that matches search parameters. :param name: Name of entity to search. :type name: str @@ -2389,7 +2630,7 @@ async def find_model_artifact( :type _host_index: int, optional :return: Returns the result object. """ # noqa: E501 - _param = self._find_model_artifact_serialize( + _param = self._find_inference_service_serialize( name=name, external_id=external_id, parent_resource_id=parent_resource_id, @@ -2400,7 +2641,7 @@ async def find_model_artifact( ) _response_types_map: dict[str, Optional[str]] = { - "200": "ModelArtifact", + "200": "InferenceService", "400": "Error", "401": "Error", "404": "Error", @@ -2414,7 +2655,7 @@ async def find_model_artifact( ).data @validate_call - async def find_model_artifact_with_http_info( + async def find_inference_service_with_http_info( self, name: Annotated[Optional[StrictStr], Field(description="Name of entity to search.")] = None, external_id: Annotated[Optional[StrictStr], Field(description="External ID of entity to search.")] = None, @@ -2430,10 +2671,10 @@ async def find_model_artifact_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[ModelArtifact]: - """Get a ModelArtifact that matches search parameters. + ) -> ApiResponse[InferenceService]: + """Get an InferenceServices that matches search parameters. - Gets the details of a single instance of a `ModelArtifact` that matches search parameters. + Gets the details of a single instance of `InferenceService` that matches search parameters. :param name: Name of entity to search. :type name: str @@ -2462,7 +2703,7 @@ async def find_model_artifact_with_http_info( :type _host_index: int, optional :return: Returns the result object. """ # noqa: E501 - _param = self._find_model_artifact_serialize( + _param = self._find_inference_service_serialize( name=name, external_id=external_id, parent_resource_id=parent_resource_id, @@ -2473,7 +2714,7 @@ async def find_model_artifact_with_http_info( ) _response_types_map: dict[str, Optional[str]] = { - "200": "ModelArtifact", + "200": "InferenceService", "400": "Error", "401": "Error", "404": "Error", @@ -2487,7 +2728,7 @@ async def find_model_artifact_with_http_info( ) @validate_call - async def find_model_artifact_without_preload_content( + async def find_inference_service_without_preload_content( self, name: Annotated[Optional[StrictStr], Field(description="Name of entity to search.")] = None, external_id: Annotated[Optional[StrictStr], Field(description="External ID of entity to search.")] = None, @@ -2504,9 +2745,9 @@ async def find_model_artifact_without_preload_content( _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Get a ModelArtifact that matches search parameters. + """Get an InferenceServices that matches search parameters. - Gets the details of a single instance of a `ModelArtifact` that matches search parameters. + Gets the details of a single instance of `InferenceService` that matches search parameters. :param name: Name of entity to search. :type name: str @@ -2535,7 +2776,7 @@ async def find_model_artifact_without_preload_content( :type _host_index: int, optional :return: Returns the result object. """ # noqa: E501 - _param = self._find_model_artifact_serialize( + _param = self._find_inference_service_serialize( name=name, external_id=external_id, parent_resource_id=parent_resource_id, @@ -2546,7 +2787,7 @@ async def find_model_artifact_without_preload_content( ) _response_types_map: dict[str, Optional[str]] = { - "200": "ModelArtifact", + "200": "InferenceService", "400": "Error", "401": "Error", "404": "Error", @@ -2555,7 +2796,7 @@ async def find_model_artifact_without_preload_content( response_data = await self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _find_model_artifact_serialize( + def _find_inference_service_serialize( self, name, external_id, @@ -2603,7 +2844,7 @@ def _find_model_artifact_serialize( return self.api_client.param_serialize( method="GET", - resource_path="/api/model_registry/v1alpha3/model_artifact", + resource_path="/api/model_registry/v1alpha3/inference_service", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -2617,7 +2858,7 @@ def _find_model_artifact_serialize( ) @validate_call - async def find_model_version( + async def find_model_artifact( self, name: Annotated[Optional[StrictStr], Field(description="Name of entity to search.")] = None, external_id: Annotated[Optional[StrictStr], Field(description="External ID of entity to search.")] = None, @@ -2633,10 +2874,10 @@ async def find_model_version( _content_type: Optional[StrictStr] = None, _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ModelVersion: - """Get a ModelVersion that matches search parameters. + ) -> ModelArtifact: + """Get a ModelArtifact that matches search parameters. - Gets the details of a single instance of a `ModelVersion` that matches search parameters. + Gets the details of a single instance of a `ModelArtifact` that matches search parameters. :param name: Name of entity to search. :type name: str @@ -2665,7 +2906,7 @@ async def find_model_version( :type _host_index: int, optional :return: Returns the result object. """ # noqa: E501 - _param = self._find_model_version_serialize( + _param = self._find_model_artifact_serialize( name=name, external_id=external_id, parent_resource_id=parent_resource_id, @@ -2676,7 +2917,7 @@ async def find_model_version( ) _response_types_map: dict[str, Optional[str]] = { - "200": "ModelVersion", + "200": "ModelArtifact", "400": "Error", "401": "Error", "404": "Error", @@ -2690,7 +2931,7 @@ async def find_model_version( ).data @validate_call - async def find_model_version_with_http_info( + async def find_model_artifact_with_http_info( self, name: Annotated[Optional[StrictStr], Field(description="Name of entity to search.")] = None, external_id: Annotated[Optional[StrictStr], Field(description="External ID of entity to search.")] = None, @@ -2706,10 +2947,10 @@ async def find_model_version_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[ModelVersion]: - """Get a ModelVersion that matches search parameters. + ) -> ApiResponse[ModelArtifact]: + """Get a ModelArtifact that matches search parameters. - Gets the details of a single instance of a `ModelVersion` that matches search parameters. + Gets the details of a single instance of a `ModelArtifact` that matches search parameters. :param name: Name of entity to search. :type name: str @@ -2738,7 +2979,7 @@ async def find_model_version_with_http_info( :type _host_index: int, optional :return: Returns the result object. """ # noqa: E501 - _param = self._find_model_version_serialize( + _param = self._find_model_artifact_serialize( name=name, external_id=external_id, parent_resource_id=parent_resource_id, @@ -2749,7 +2990,7 @@ async def find_model_version_with_http_info( ) _response_types_map: dict[str, Optional[str]] = { - "200": "ModelVersion", + "200": "ModelArtifact", "400": "Error", "401": "Error", "404": "Error", @@ -2763,7 +3004,7 @@ async def find_model_version_with_http_info( ) @validate_call - async def find_model_version_without_preload_content( + async def find_model_artifact_without_preload_content( self, name: Annotated[Optional[StrictStr], Field(description="Name of entity to search.")] = None, external_id: Annotated[Optional[StrictStr], Field(description="External ID of entity to search.")] = None, @@ -2780,9 +3021,9 @@ async def find_model_version_without_preload_content( _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Get a ModelVersion that matches search parameters. + """Get a ModelArtifact that matches search parameters. - Gets the details of a single instance of a `ModelVersion` that matches search parameters. + Gets the details of a single instance of a `ModelArtifact` that matches search parameters. :param name: Name of entity to search. :type name: str @@ -2811,7 +3052,7 @@ async def find_model_version_without_preload_content( :type _host_index: int, optional :return: Returns the result object. """ # noqa: E501 - _param = self._find_model_version_serialize( + _param = self._find_model_artifact_serialize( name=name, external_id=external_id, parent_resource_id=parent_resource_id, @@ -2822,7 +3063,7 @@ async def find_model_version_without_preload_content( ) _response_types_map: dict[str, Optional[str]] = { - "200": "ModelVersion", + "200": "ModelArtifact", "400": "Error", "401": "Error", "404": "Error", @@ -2831,7 +3072,7 @@ async def find_model_version_without_preload_content( response_data = await self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _find_model_version_serialize( + def _find_model_artifact_serialize( self, name, external_id, @@ -2879,7 +3120,7 @@ def _find_model_version_serialize( return self.api_client.param_serialize( method="GET", - resource_path="/api/model_registry/v1alpha3/model_version", + resource_path="/api/model_registry/v1alpha3/model_artifact", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -2893,10 +3134,13 @@ def _find_model_version_serialize( ) @validate_call - async def find_registered_model( + async def find_model_version( self, name: Annotated[Optional[StrictStr], Field(description="Name of entity to search.")] = None, external_id: Annotated[Optional[StrictStr], Field(description="External ID of entity to search.")] = None, + parent_resource_id: Annotated[ + Optional[StrictStr], Field(description="ID of the parent resource to use for search.") + ] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -2906,15 +3150,17 @@ async def find_registered_model( _content_type: Optional[StrictStr] = None, _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> RegisteredModel: - """Get a RegisteredModel that matches search parameters. + ) -> ModelVersion: + """Get a ModelVersion that matches search parameters. - Gets the details of a single instance of a `RegisteredModel` that matches search parameters. + Gets the details of a single instance of a `ModelVersion` that matches search parameters. :param name: Name of entity to search. :type name: str :param external_id: External ID of entity to search. :type external_id: str + :param parent_resource_id: ID of the parent resource to use for search. + :type parent_resource_id: str :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -2936,9 +3182,10 @@ async def find_registered_model( :type _host_index: int, optional :return: Returns the result object. """ # noqa: E501 - _param = self._find_registered_model_serialize( + _param = self._find_model_version_serialize( name=name, external_id=external_id, + parent_resource_id=parent_resource_id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -2946,7 +3193,8 @@ async def find_registered_model( ) _response_types_map: dict[str, Optional[str]] = { - "200": "RegisteredModel", + "200": "ModelVersion", + "400": "Error", "401": "Error", "404": "Error", "500": "Error", @@ -2959,10 +3207,13 @@ async def find_registered_model( ).data @validate_call - async def find_registered_model_with_http_info( + async def find_model_version_with_http_info( self, name: Annotated[Optional[StrictStr], Field(description="Name of entity to search.")] = None, external_id: Annotated[Optional[StrictStr], Field(description="External ID of entity to search.")] = None, + parent_resource_id: Annotated[ + Optional[StrictStr], Field(description="ID of the parent resource to use for search.") + ] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -2972,15 +3223,17 @@ async def find_registered_model_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[RegisteredModel]: - """Get a RegisteredModel that matches search parameters. + ) -> ApiResponse[ModelVersion]: + """Get a ModelVersion that matches search parameters. - Gets the details of a single instance of a `RegisteredModel` that matches search parameters. + Gets the details of a single instance of a `ModelVersion` that matches search parameters. :param name: Name of entity to search. :type name: str :param external_id: External ID of entity to search. :type external_id: str + :param parent_resource_id: ID of the parent resource to use for search. + :type parent_resource_id: str :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -3002,9 +3255,10 @@ async def find_registered_model_with_http_info( :type _host_index: int, optional :return: Returns the result object. """ # noqa: E501 - _param = self._find_registered_model_serialize( + _param = self._find_model_version_serialize( name=name, external_id=external_id, + parent_resource_id=parent_resource_id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -3012,7 +3266,8 @@ async def find_registered_model_with_http_info( ) _response_types_map: dict[str, Optional[str]] = { - "200": "RegisteredModel", + "200": "ModelVersion", + "400": "Error", "401": "Error", "404": "Error", "500": "Error", @@ -3025,10 +3280,13 @@ async def find_registered_model_with_http_info( ) @validate_call - async def find_registered_model_without_preload_content( + async def find_model_version_without_preload_content( self, name: Annotated[Optional[StrictStr], Field(description="Name of entity to search.")] = None, external_id: Annotated[Optional[StrictStr], Field(description="External ID of entity to search.")] = None, + parent_resource_id: Annotated[ + Optional[StrictStr], Field(description="ID of the parent resource to use for search.") + ] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -3039,14 +3297,16 @@ async def find_registered_model_without_preload_content( _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Get a RegisteredModel that matches search parameters. + """Get a ModelVersion that matches search parameters. - Gets the details of a single instance of a `RegisteredModel` that matches search parameters. + Gets the details of a single instance of a `ModelVersion` that matches search parameters. :param name: Name of entity to search. :type name: str :param external_id: External ID of entity to search. :type external_id: str + :param parent_resource_id: ID of the parent resource to use for search. + :type parent_resource_id: str :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -3068,9 +3328,10 @@ async def find_registered_model_without_preload_content( :type _host_index: int, optional :return: Returns the result object. """ # noqa: E501 - _param = self._find_registered_model_serialize( + _param = self._find_model_version_serialize( name=name, external_id=external_id, + parent_resource_id=parent_resource_id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -3078,7 +3339,8 @@ async def find_registered_model_without_preload_content( ) _response_types_map: dict[str, Optional[str]] = { - "200": "RegisteredModel", + "200": "ModelVersion", + "400": "Error", "401": "Error", "404": "Error", "500": "Error", @@ -3086,10 +3348,11 @@ async def find_registered_model_without_preload_content( response_data = await self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _find_registered_model_serialize( + def _find_model_version_serialize( self, name, external_id, + parent_resource_id, _request_auth, _content_type, _headers, @@ -3117,6 +3380,10 @@ def _find_registered_model_serialize( _query_params.append(("externalId", external_id)) + if parent_resource_id is not None: + + _query_params.append(("parentResourceId", parent_resource_id)) + # process the header parameters # process the form parameters # process the body parameter @@ -3129,7 +3396,7 @@ def _find_registered_model_serialize( return self.api_client.param_serialize( method="GET", - resource_path="/api/model_registry/v1alpha3/registered_model", + resource_path="/api/model_registry/v1alpha3/model_version", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -3143,7 +3410,7 @@ def _find_registered_model_serialize( ) @validate_call - async def find_serving_environment( + async def find_registered_model( self, name: Annotated[Optional[StrictStr], Field(description="Name of entity to search.")] = None, external_id: Annotated[Optional[StrictStr], Field(description="External ID of entity to search.")] = None, @@ -3156,10 +3423,10 @@ async def find_serving_environment( _content_type: Optional[StrictStr] = None, _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ServingEnvironment: - """Find ServingEnvironment. + ) -> RegisteredModel: + """Get a RegisteredModel that matches search parameters. - Finds a `ServingEnvironment` entity that matches query parameters. + Gets the details of a single instance of a `RegisteredModel` that matches search parameters. :param name: Name of entity to search. :type name: str @@ -3186,7 +3453,7 @@ async def find_serving_environment( :type _host_index: int, optional :return: Returns the result object. """ # noqa: E501 - _param = self._find_serving_environment_serialize( + _param = self._find_registered_model_serialize( name=name, external_id=external_id, _request_auth=_request_auth, @@ -3196,7 +3463,7 @@ async def find_serving_environment( ) _response_types_map: dict[str, Optional[str]] = { - "200": "ServingEnvironment", + "200": "RegisteredModel", "401": "Error", "404": "Error", "500": "Error", @@ -3209,7 +3476,7 @@ async def find_serving_environment( ).data @validate_call - async def find_serving_environment_with_http_info( + async def find_registered_model_with_http_info( self, name: Annotated[Optional[StrictStr], Field(description="Name of entity to search.")] = None, external_id: Annotated[Optional[StrictStr], Field(description="External ID of entity to search.")] = None, @@ -3222,10 +3489,10 @@ async def find_serving_environment_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[ServingEnvironment]: - """Find ServingEnvironment. + ) -> ApiResponse[RegisteredModel]: + """Get a RegisteredModel that matches search parameters. - Finds a `ServingEnvironment` entity that matches query parameters. + Gets the details of a single instance of a `RegisteredModel` that matches search parameters. :param name: Name of entity to search. :type name: str @@ -3252,7 +3519,7 @@ async def find_serving_environment_with_http_info( :type _host_index: int, optional :return: Returns the result object. """ # noqa: E501 - _param = self._find_serving_environment_serialize( + _param = self._find_registered_model_serialize( name=name, external_id=external_id, _request_auth=_request_auth, @@ -3262,7 +3529,7 @@ async def find_serving_environment_with_http_info( ) _response_types_map: dict[str, Optional[str]] = { - "200": "ServingEnvironment", + "200": "RegisteredModel", "401": "Error", "404": "Error", "500": "Error", @@ -3275,7 +3542,7 @@ async def find_serving_environment_with_http_info( ) @validate_call - async def find_serving_environment_without_preload_content( + async def find_registered_model_without_preload_content( self, name: Annotated[Optional[StrictStr], Field(description="Name of entity to search.")] = None, external_id: Annotated[Optional[StrictStr], Field(description="External ID of entity to search.")] = None, @@ -3289,9 +3556,9 @@ async def find_serving_environment_without_preload_content( _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Find ServingEnvironment. + """Get a RegisteredModel that matches search parameters. - Finds a `ServingEnvironment` entity that matches query parameters. + Gets the details of a single instance of a `RegisteredModel` that matches search parameters. :param name: Name of entity to search. :type name: str @@ -3318,9 +3585,772 @@ async def find_serving_environment_without_preload_content( :type _host_index: int, optional :return: Returns the result object. """ # noqa: E501 - _param = self._find_serving_environment_serialize( - name=name, - external_id=external_id, + _param = self._find_registered_model_serialize( + name=name, + external_id=external_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: dict[str, Optional[str]] = { + "200": "RegisteredModel", + "401": "Error", + "404": "Error", + "500": "Error", + } + response_data = await self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _find_registered_model_serialize( + self, + name, + external_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: dict[str, str] = {} + + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, Optional[str]] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if name is not None: + + _query_params.append(("name", name)) + + if external_id is not None: + + _query_params.append(("externalId", external_id)) + + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: list[str] = ["Bearer"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/api/model_registry/v1alpha3/registered_model", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + async def find_serving_environment( + self, + name: Annotated[Optional[StrictStr], Field(description="Name of entity to search.")] = None, + external_id: Annotated[Optional[StrictStr], Field(description="External ID of entity to search.")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ServingEnvironment: + """Find ServingEnvironment. + + Finds a `ServingEnvironment` entity that matches query parameters. + + :param name: Name of entity to search. + :type name: str + :param external_id: External ID of entity to search. + :type external_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + _param = self._find_serving_environment_serialize( + name=name, + external_id=external_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: dict[str, Optional[str]] = { + "200": "ServingEnvironment", + "401": "Error", + "404": "Error", + "500": "Error", + } + response_data = await self.api_client.call_api(*_param, _request_timeout=_request_timeout) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + async def find_serving_environment_with_http_info( + self, + name: Annotated[Optional[StrictStr], Field(description="Name of entity to search.")] = None, + external_id: Annotated[Optional[StrictStr], Field(description="External ID of entity to search.")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[ServingEnvironment]: + """Find ServingEnvironment. + + Finds a `ServingEnvironment` entity that matches query parameters. + + :param name: Name of entity to search. + :type name: str + :param external_id: External ID of entity to search. + :type external_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + _param = self._find_serving_environment_serialize( + name=name, + external_id=external_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: dict[str, Optional[str]] = { + "200": "ServingEnvironment", + "401": "Error", + "404": "Error", + "500": "Error", + } + response_data = await self.api_client.call_api(*_param, _request_timeout=_request_timeout) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + async def find_serving_environment_without_preload_content( + self, + name: Annotated[Optional[StrictStr], Field(description="Name of entity to search.")] = None, + external_id: Annotated[Optional[StrictStr], Field(description="External ID of entity to search.")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Find ServingEnvironment. + + Finds a `ServingEnvironment` entity that matches query parameters. + + :param name: Name of entity to search. + :type name: str + :param external_id: External ID of entity to search. + :type external_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + _param = self._find_serving_environment_serialize( + name=name, + external_id=external_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: dict[str, Optional[str]] = { + "200": "ServingEnvironment", + "401": "Error", + "404": "Error", + "500": "Error", + } + response_data = await self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _find_serving_environment_serialize( + self, + name, + external_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: dict[str, str] = {} + + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, Optional[str]] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if name is not None: + + _query_params.append(("name", name)) + + if external_id is not None: + + _query_params.append(("externalId", external_id)) + + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: list[str] = ["Bearer"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/api/model_registry/v1alpha3/serving_environment", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + async def get_artifact( + self, + id: Annotated[StrictStr, Field(description="A unique identifier for an `Artifact`.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Artifact: + """Get an Artifact. + + Gets the details of a single instance of an `Artifact`. + + :param id: A unique identifier for an `Artifact`. (required) + :type id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + _param = self._get_artifact_serialize( + id=id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index + ) + + _response_types_map: dict[str, Optional[str]] = { + "200": "Artifact", + "401": "Error", + "404": "Error", + "500": "Error", + } + response_data = await self.api_client.call_api(*_param, _request_timeout=_request_timeout) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + async def get_artifact_with_http_info( + self, + id: Annotated[StrictStr, Field(description="A unique identifier for an `Artifact`.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Artifact]: + """Get an Artifact. + + Gets the details of a single instance of an `Artifact`. + + :param id: A unique identifier for an `Artifact`. (required) + :type id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + _param = self._get_artifact_serialize( + id=id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index + ) + + _response_types_map: dict[str, Optional[str]] = { + "200": "Artifact", + "401": "Error", + "404": "Error", + "500": "Error", + } + response_data = await self.api_client.call_api(*_param, _request_timeout=_request_timeout) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + async def get_artifact_without_preload_content( + self, + id: Annotated[StrictStr, Field(description="A unique identifier for an `Artifact`.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get an Artifact. + + Gets the details of a single instance of an `Artifact`. + + :param id: A unique identifier for an `Artifact`. (required) + :type id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + _param = self._get_artifact_serialize( + id=id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index + ) + + _response_types_map: dict[str, Optional[str]] = { + "200": "Artifact", + "401": "Error", + "404": "Error", + "500": "Error", + } + response_data = await self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_artifact_serialize( + self, + id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: dict[str, str] = {} + + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, Optional[str]] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if id is not None: + _path_params["id"] = id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: list[str] = ["Bearer"] + + return self.api_client.param_serialize( + method="GET", + resource_path="/api/model_registry/v1alpha3/artifacts/{id}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + async def get_artifacts( + self, + page_size: Annotated[Optional[StrictStr], Field(description="Number of entities in each page.")] = None, + order_by: Annotated[ + Optional[OrderByField], Field(description="Specifies the order by criteria for listing entities.") + ] = None, + sort_order: Annotated[ + Optional[SortOrder], Field(description="Specifies the sort order for listing entities, defaults to ASC.") + ] = None, + next_page_token: Annotated[ + Optional[StrictStr], Field(description="Token to use to retrieve next page of results.") + ] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ArtifactList: + """List All Artifacts. + + Gets a list of all `Artifact` entities. + + :param page_size: Number of entities in each page. + :type page_size: str + :param order_by: Specifies the order by criteria for listing entities. + :type order_by: OrderByField + :param sort_order: Specifies the sort order for listing entities, defaults to ASC. + :type sort_order: SortOrder + :param next_page_token: Token to use to retrieve next page of results. + :type next_page_token: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + _param = self._get_artifacts_serialize( + page_size=page_size, + order_by=order_by, + sort_order=sort_order, + next_page_token=next_page_token, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: dict[str, Optional[str]] = { + "200": "ArtifactList", + "400": "Error", + "401": "Error", + "404": "Error", + "500": "Error", + } + response_data = await self.api_client.call_api(*_param, _request_timeout=_request_timeout) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + async def get_artifacts_with_http_info( + self, + page_size: Annotated[Optional[StrictStr], Field(description="Number of entities in each page.")] = None, + order_by: Annotated[ + Optional[OrderByField], Field(description="Specifies the order by criteria for listing entities.") + ] = None, + sort_order: Annotated[ + Optional[SortOrder], Field(description="Specifies the sort order for listing entities, defaults to ASC.") + ] = None, + next_page_token: Annotated[ + Optional[StrictStr], Field(description="Token to use to retrieve next page of results.") + ] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[ArtifactList]: + """List All Artifacts. + + Gets a list of all `Artifact` entities. + + :param page_size: Number of entities in each page. + :type page_size: str + :param order_by: Specifies the order by criteria for listing entities. + :type order_by: OrderByField + :param sort_order: Specifies the sort order for listing entities, defaults to ASC. + :type sort_order: SortOrder + :param next_page_token: Token to use to retrieve next page of results. + :type next_page_token: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + _param = self._get_artifacts_serialize( + page_size=page_size, + order_by=order_by, + sort_order=sort_order, + next_page_token=next_page_token, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: dict[str, Optional[str]] = { + "200": "ArtifactList", + "400": "Error", + "401": "Error", + "404": "Error", + "500": "Error", + } + response_data = await self.api_client.call_api(*_param, _request_timeout=_request_timeout) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + async def get_artifacts_without_preload_content( + self, + page_size: Annotated[Optional[StrictStr], Field(description="Number of entities in each page.")] = None, + order_by: Annotated[ + Optional[OrderByField], Field(description="Specifies the order by criteria for listing entities.") + ] = None, + sort_order: Annotated[ + Optional[SortOrder], Field(description="Specifies the sort order for listing entities, defaults to ASC.") + ] = None, + next_page_token: Annotated[ + Optional[StrictStr], Field(description="Token to use to retrieve next page of results.") + ] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """List All Artifacts. + + Gets a list of all `Artifact` entities. + + :param page_size: Number of entities in each page. + :type page_size: str + :param order_by: Specifies the order by criteria for listing entities. + :type order_by: OrderByField + :param sort_order: Specifies the sort order for listing entities, defaults to ASC. + :type sort_order: SortOrder + :param next_page_token: Token to use to retrieve next page of results. + :type next_page_token: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + _param = self._get_artifacts_serialize( + page_size=page_size, + order_by=order_by, + sort_order=sort_order, + next_page_token=next_page_token, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -3328,7 +4358,8 @@ async def find_serving_environment_without_preload_content( ) _response_types_map: dict[str, Optional[str]] = { - "200": "ServingEnvironment", + "200": "ArtifactList", + "400": "Error", "401": "Error", "404": "Error", "500": "Error", @@ -3336,10 +4367,12 @@ async def find_serving_environment_without_preload_content( response_data = await self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _find_serving_environment_serialize( + def _get_artifacts_serialize( self, - name, - external_id, + page_size, + order_by, + sort_order, + next_page_token, _request_auth, _content_type, _headers, @@ -3359,13 +4392,21 @@ def _find_serving_environment_serialize( # process the path parameters # process the query parameters - if name is not None: + if page_size is not None: - _query_params.append(("name", name)) + _query_params.append(("pageSize", page_size)) - if external_id is not None: + if order_by is not None: - _query_params.append(("externalId", external_id)) + _query_params.append(("orderBy", order_by.value)) + + if sort_order is not None: + + _query_params.append(("sortOrder", sort_order.value)) + + if next_page_token is not None: + + _query_params.append(("nextPageToken", next_page_token)) # process the header parameters # process the form parameters @@ -3379,7 +4420,7 @@ def _find_serving_environment_serialize( return self.api_client.param_serialize( method="GET", - resource_path="/api/model_registry/v1alpha3/serving_environment", + resource_path="/api/model_registry/v1alpha3/artifacts", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -7926,6 +8967,263 @@ def _get_serving_environments_serialize( _request_auth=_request_auth, ) + @validate_call + async def update_artifact( + self, + id: Annotated[StrictStr, Field(description="A unique identifier for an `Artifact`.")], + artifact_update: Annotated[ArtifactUpdate, Field(description="Updated `Artifact` information.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Artifact: + """Update an Artifact. + + Updates an existing `Artifact`. + + :param id: A unique identifier for an `Artifact`. (required) + :type id: str + :param artifact_update: Updated `Artifact` information. (required) + :type artifact_update: ArtifactUpdate + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + _param = self._update_artifact_serialize( + id=id, + artifact_update=artifact_update, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: dict[str, Optional[str]] = { + "200": "Artifact", + "400": "Error", + "401": "Error", + "404": "Error", + "500": "Error", + } + response_data = await self.api_client.call_api(*_param, _request_timeout=_request_timeout) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + async def update_artifact_with_http_info( + self, + id: Annotated[StrictStr, Field(description="A unique identifier for an `Artifact`.")], + artifact_update: Annotated[ArtifactUpdate, Field(description="Updated `Artifact` information.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Artifact]: + """Update an Artifact. + + Updates an existing `Artifact`. + + :param id: A unique identifier for an `Artifact`. (required) + :type id: str + :param artifact_update: Updated `Artifact` information. (required) + :type artifact_update: ArtifactUpdate + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + _param = self._update_artifact_serialize( + id=id, + artifact_update=artifact_update, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: dict[str, Optional[str]] = { + "200": "Artifact", + "400": "Error", + "401": "Error", + "404": "Error", + "500": "Error", + } + response_data = await self.api_client.call_api(*_param, _request_timeout=_request_timeout) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + async def update_artifact_without_preload_content( + self, + id: Annotated[StrictStr, Field(description="A unique identifier for an `Artifact`.")], + artifact_update: Annotated[ArtifactUpdate, Field(description="Updated `Artifact` information.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Update an Artifact. + + Updates an existing `Artifact`. + + :param id: A unique identifier for an `Artifact`. (required) + :type id: str + :param artifact_update: Updated `Artifact` information. (required) + :type artifact_update: ArtifactUpdate + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + _param = self._update_artifact_serialize( + id=id, + artifact_update=artifact_update, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: dict[str, Optional[str]] = { + "200": "Artifact", + "400": "Error", + "401": "Error", + "404": "Error", + "500": "Error", + } + response_data = await self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _update_artifact_serialize( + self, + id, + artifact_update, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: dict[str, str] = {} + + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, Optional[str]] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if id is not None: + _path_params["id"] = id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if artifact_update is not None: + _body_params = artifact_update + + # set the HTTP header `Accept` + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: list[str] = ["Bearer"] + + return self.api_client.param_serialize( + method="PATCH", + resource_path="/api/model_registry/v1alpha3/artifacts/{id}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + @validate_call async def update_inference_service( self, diff --git a/clients/python/src/mr_openapi/models/__init__.py b/clients/python/src/mr_openapi/models/__init__.py index ceb6da35..c4e8bd49 100644 --- a/clients/python/src/mr_openapi/models/__init__.py +++ b/clients/python/src/mr_openapi/models/__init__.py @@ -15,8 +15,10 @@ # import models into model package from mr_openapi.models.artifact import Artifact +from mr_openapi.models.artifact_create import ArtifactCreate from mr_openapi.models.artifact_list import ArtifactList from mr_openapi.models.artifact_state import ArtifactState +from mr_openapi.models.artifact_update import ArtifactUpdate from mr_openapi.models.base_artifact import BaseArtifact from mr_openapi.models.base_artifact_create import BaseArtifactCreate from mr_openapi.models.base_artifact_update import BaseArtifactUpdate @@ -28,6 +30,8 @@ from mr_openapi.models.base_resource_list import BaseResourceList from mr_openapi.models.base_resource_update import BaseResourceUpdate from mr_openapi.models.doc_artifact import DocArtifact +from mr_openapi.models.doc_artifact_create import DocArtifactCreate +from mr_openapi.models.doc_artifact_update import DocArtifactUpdate from mr_openapi.models.error import Error from mr_openapi.models.execution_state import ExecutionState from mr_openapi.models.inference_service import InferenceService diff --git a/clients/python/src/mr_openapi/models/artifact_create.py b/clients/python/src/mr_openapi/models/artifact_create.py new file mode 100644 index 00000000..dfae6989 --- /dev/null +++ b/clients/python/src/mr_openapi/models/artifact_create.py @@ -0,0 +1,174 @@ +"""Model Registry REST API. + +REST API for Model Registry to create and manage ML model metadata + +The version of the OpenAPI document: v1alpha3 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +from typing import Any + +from pydantic import ( + BaseModel, + ConfigDict, + ValidationError, + field_validator, +) +from typing_extensions import Self + +from mr_openapi.models.doc_artifact_create import DocArtifactCreate +from mr_openapi.models.model_artifact_create import ModelArtifactCreate + +ARTIFACTCREATE_ONE_OF_SCHEMAS = ["DocArtifactCreate", "ModelArtifactCreate"] + + +class ArtifactCreate(BaseModel): + """An Artifact to be created.""" + + # data type: ModelArtifactCreate + oneof_schema_1_validator: ModelArtifactCreate | None = None + # data type: DocArtifactCreate + oneof_schema_2_validator: DocArtifactCreate | None = None + actual_instance: DocArtifactCreate | ModelArtifactCreate | None = None + one_of_schemas: set[str] = {"DocArtifactCreate", "ModelArtifactCreate"} + + model_config = ConfigDict( + validate_assignment=True, + protected_namespaces=(), + ) + + discriminator_value_class_map: dict[str, str] = {} + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + msg = "If a position argument is used, only 1 is allowed to set `actual_instance`" + raise ValueError(msg) + if kwargs: + msg = "If a position argument is used, keyword arguments cannot be used." + raise ValueError(msg) + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @field_validator("actual_instance") + def actual_instance_must_validate_oneof(cls, v): + ArtifactCreate.model_construct() + error_messages = [] + match = 0 + # validate data type: ModelArtifactCreate + if not isinstance(v, ModelArtifactCreate): + error_messages.append(f"Error! Input type `{type(v)}` is not `ModelArtifactCreate`") + else: + match += 1 + # validate data type: DocArtifactCreate + if not isinstance(v, DocArtifactCreate): + error_messages.append(f"Error! Input type `{type(v)}` is not `DocArtifactCreate`") + else: + match += 1 + if match > 1: + # more than 1 match + raise ValueError( + "Multiple matches found when setting `actual_instance` in ArtifactCreate with oneOf schemas: DocArtifactCreate, ModelArtifactCreate. Details: " + + ", ".join(error_messages) + ) + if match == 0: + # no match + raise ValueError( + "No match found when setting `actual_instance` in ArtifactCreate with oneOf schemas: DocArtifactCreate, ModelArtifactCreate. Details: " + + ", ".join(error_messages) + ) + return v + + @classmethod + def from_dict(cls, obj: str | dict[str, Any]) -> Self: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string.""" + instance = cls.model_construct() + error_messages = [] + match = 0 + + # use oneOf discriminator to lookup the data type + _data_type = json.loads(json_str).get("artifactType") + if not _data_type: + msg = "Failed to lookup data type from the field `artifactType` in the input." + raise ValueError(msg) + + # check if data type is `DocArtifactCreate` + if _data_type == "doc-artifact": + instance.actual_instance = DocArtifactCreate.from_json(json_str) + return instance + + # check if data type is `ModelArtifactCreate` + if _data_type == "model-artifact": + instance.actual_instance = ModelArtifactCreate.from_json(json_str) + return instance + + # check if data type is `DocArtifactCreate` + if _data_type == "DocArtifactCreate": + instance.actual_instance = DocArtifactCreate.from_json(json_str) + return instance + + # check if data type is `ModelArtifactCreate` + if _data_type == "ModelArtifactCreate": + instance.actual_instance = ModelArtifactCreate.from_json(json_str) + return instance + + # deserialize data into ModelArtifactCreate + try: + instance.actual_instance = ModelArtifactCreate.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into DocArtifactCreate + try: + instance.actual_instance = DocArtifactCreate.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError( + "Multiple matches found when deserializing the JSON string into ArtifactCreate with oneOf schemas: DocArtifactCreate, ModelArtifactCreate. Details: " + + ", ".join(error_messages) + ) + if match == 0: + # no match + raise ValueError( + "No match found when deserializing the JSON string into ArtifactCreate with oneOf schemas: DocArtifactCreate, ModelArtifactCreate. Details: " + + ", ".join(error_messages) + ) + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance.""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): + return self.actual_instance.to_json() + return json.dumps(self.actual_instance) + + def to_dict(self) -> dict[str, Any] | DocArtifactCreate | ModelArtifactCreate | None: + """Returns the dict representation of the actual instance.""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): + return self.actual_instance.to_dict() + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance.""" + return pprint.pformat(self.model_dump()) diff --git a/clients/python/src/mr_openapi/models/artifact_update.py b/clients/python/src/mr_openapi/models/artifact_update.py new file mode 100644 index 00000000..8484d0a2 --- /dev/null +++ b/clients/python/src/mr_openapi/models/artifact_update.py @@ -0,0 +1,174 @@ +"""Model Registry REST API. + +REST API for Model Registry to create and manage ML model metadata + +The version of the OpenAPI document: v1alpha3 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +from typing import Any + +from pydantic import ( + BaseModel, + ConfigDict, + ValidationError, + field_validator, +) +from typing_extensions import Self + +from mr_openapi.models.doc_artifact_update import DocArtifactUpdate +from mr_openapi.models.model_artifact_update import ModelArtifactUpdate + +ARTIFACTUPDATE_ONE_OF_SCHEMAS = ["DocArtifactUpdate", "ModelArtifactUpdate"] + + +class ArtifactUpdate(BaseModel): + """An Artifact to be updated.""" + + # data type: ModelArtifactUpdate + oneof_schema_1_validator: ModelArtifactUpdate | None = None + # data type: DocArtifactUpdate + oneof_schema_2_validator: DocArtifactUpdate | None = None + actual_instance: DocArtifactUpdate | ModelArtifactUpdate | None = None + one_of_schemas: set[str] = {"DocArtifactUpdate", "ModelArtifactUpdate"} + + model_config = ConfigDict( + validate_assignment=True, + protected_namespaces=(), + ) + + discriminator_value_class_map: dict[str, str] = {} + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + msg = "If a position argument is used, only 1 is allowed to set `actual_instance`" + raise ValueError(msg) + if kwargs: + msg = "If a position argument is used, keyword arguments cannot be used." + raise ValueError(msg) + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @field_validator("actual_instance") + def actual_instance_must_validate_oneof(cls, v): + ArtifactUpdate.model_construct() + error_messages = [] + match = 0 + # validate data type: ModelArtifactUpdate + if not isinstance(v, ModelArtifactUpdate): + error_messages.append(f"Error! Input type `{type(v)}` is not `ModelArtifactUpdate`") + else: + match += 1 + # validate data type: DocArtifactUpdate + if not isinstance(v, DocArtifactUpdate): + error_messages.append(f"Error! Input type `{type(v)}` is not `DocArtifactUpdate`") + else: + match += 1 + if match > 1: + # more than 1 match + raise ValueError( + "Multiple matches found when setting `actual_instance` in ArtifactUpdate with oneOf schemas: DocArtifactUpdate, ModelArtifactUpdate. Details: " + + ", ".join(error_messages) + ) + if match == 0: + # no match + raise ValueError( + "No match found when setting `actual_instance` in ArtifactUpdate with oneOf schemas: DocArtifactUpdate, ModelArtifactUpdate. Details: " + + ", ".join(error_messages) + ) + return v + + @classmethod + def from_dict(cls, obj: str | dict[str, Any]) -> Self: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string.""" + instance = cls.model_construct() + error_messages = [] + match = 0 + + # use oneOf discriminator to lookup the data type + _data_type = json.loads(json_str).get("artifactType") + if not _data_type: + msg = "Failed to lookup data type from the field `artifactType` in the input." + raise ValueError(msg) + + # check if data type is `DocArtifactUpdate` + if _data_type == "doc-artifact": + instance.actual_instance = DocArtifactUpdate.from_json(json_str) + return instance + + # check if data type is `ModelArtifactUpdate` + if _data_type == "model-artifact": + instance.actual_instance = ModelArtifactUpdate.from_json(json_str) + return instance + + # check if data type is `DocArtifactUpdate` + if _data_type == "DocArtifactUpdate": + instance.actual_instance = DocArtifactUpdate.from_json(json_str) + return instance + + # check if data type is `ModelArtifactUpdate` + if _data_type == "ModelArtifactUpdate": + instance.actual_instance = ModelArtifactUpdate.from_json(json_str) + return instance + + # deserialize data into ModelArtifactUpdate + try: + instance.actual_instance = ModelArtifactUpdate.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into DocArtifactUpdate + try: + instance.actual_instance = DocArtifactUpdate.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError( + "Multiple matches found when deserializing the JSON string into ArtifactUpdate with oneOf schemas: DocArtifactUpdate, ModelArtifactUpdate. Details: " + + ", ".join(error_messages) + ) + if match == 0: + # no match + raise ValueError( + "No match found when deserializing the JSON string into ArtifactUpdate with oneOf schemas: DocArtifactUpdate, ModelArtifactUpdate. Details: " + + ", ".join(error_messages) + ) + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance.""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): + return self.actual_instance.to_json() + return json.dumps(self.actual_instance) + + def to_dict(self) -> dict[str, Any] | DocArtifactUpdate | ModelArtifactUpdate | None: + """Returns the dict representation of the actual instance.""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): + return self.actual_instance.to_dict() + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance.""" + return pprint.pformat(self.model_dump()) diff --git a/clients/python/src/mr_openapi/models/doc_artifact.py b/clients/python/src/mr_openapi/models/doc_artifact.py index a45fdd54..f7d78350 100644 --- a/clients/python/src/mr_openapi/models/doc_artifact.py +++ b/clients/python/src/mr_openapi/models/doc_artifact.py @@ -25,7 +25,6 @@ class DocArtifact(BaseModel): """A document.""" # noqa: E501 - artifact_type: StrictStr = Field(alias="artifactType") custom_properties: dict[str, MetadataValue] | None = Field( default=None, description="User provided custom properties which are not defined by its type.", @@ -57,6 +56,7 @@ class DocArtifact(BaseModel): description="Output only. Last update time of the resource since epoch in millisecond since epoch.", alias="lastUpdateTimeSinceEpoch", ) + artifact_type: StrictStr = Field(alias="artifactType") __properties: ClassVar[list[str]] = [ "customProperties", "description", @@ -67,6 +67,7 @@ class DocArtifact(BaseModel): "id", "createTimeSinceEpoch", "lastUpdateTimeSinceEpoch", + "artifactType", ] model_config = ConfigDict( @@ -145,5 +146,6 @@ def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: "id": obj.get("id"), "createTimeSinceEpoch": obj.get("createTimeSinceEpoch"), "lastUpdateTimeSinceEpoch": obj.get("lastUpdateTimeSinceEpoch"), + "artifactType": obj.get("artifactType") if obj.get("artifactType") is not None else "doc-artifact", } ) diff --git a/clients/python/src/mr_openapi/models/doc_artifact_create.py b/clients/python/src/mr_openapi/models/doc_artifact_create.py new file mode 100644 index 00000000..9a977dd3 --- /dev/null +++ b/clients/python/src/mr_openapi/models/doc_artifact_create.py @@ -0,0 +1,128 @@ +"""Model Registry REST API. + +REST API for Model Registry to create and manage ML model metadata + +The version of the OpenAPI document: v1alpha3 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +import re # noqa: F401 +from typing import Any, ClassVar + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing_extensions import Self + +from mr_openapi.models.artifact_state import ArtifactState +from mr_openapi.models.metadata_value import MetadataValue + + +class DocArtifactCreate(BaseModel): + """A document artifact to be created.""" # noqa: E501 + + custom_properties: dict[str, MetadataValue] | None = Field( + default=None, + description="User provided custom properties which are not defined by its type.", + alias="customProperties", + ) + description: StrictStr | None = Field(default=None, description="An optional description about the resource.") + external_id: StrictStr | None = Field( + default=None, + description="The external id that come from the clients’ system. This field is optional. If set, it must be unique among all resources within a database instance.", + alias="externalId", + ) + uri: StrictStr | None = Field( + default=None, + description="The uniform resource identifier of the physical artifact. May be empty if there is no physical artifact.", + ) + state: ArtifactState | None = None + name: StrictStr | None = Field( + default=None, + description="The client provided name of the artifact. This field is optional. If set, it must be unique among all the artifacts of the same artifact type within a database instance and cannot be changed once set.", + ) + artifact_type: StrictStr = Field(alias="artifactType") + __properties: ClassVar[list[str]] = [ + "customProperties", + "description", + "externalId", + "uri", + "state", + "name", + "artifactType", + ] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias.""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias.""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Self | None: + """Create an instance of DocArtifactCreate from a JSON string.""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: set[str] = set() + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each value in custom_properties (dict) + _field_dict = {} + if self.custom_properties: + for _key in self.custom_properties: + if self.custom_properties[_key]: + _field_dict[_key] = self.custom_properties[_key].to_dict() + _dict["customProperties"] = _field_dict + return _dict + + @classmethod + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: + """Create an instance of DocArtifactCreate from a dict.""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + return cls.model_validate( + { + "customProperties": ( + {_k: MetadataValue.from_dict(_v) for _k, _v in obj["customProperties"].items()} + if obj.get("customProperties") is not None + else None + ), + "description": obj.get("description"), + "externalId": obj.get("externalId"), + "uri": obj.get("uri"), + "state": obj.get("state"), + "name": obj.get("name"), + "artifactType": obj.get("artifactType") if obj.get("artifactType") is not None else "doc-artifact", + } + ) diff --git a/clients/python/src/mr_openapi/models/doc_artifact_update.py b/clients/python/src/mr_openapi/models/doc_artifact_update.py new file mode 100644 index 00000000..2461731f --- /dev/null +++ b/clients/python/src/mr_openapi/models/doc_artifact_update.py @@ -0,0 +1,122 @@ +"""Model Registry REST API. + +REST API for Model Registry to create and manage ML model metadata + +The version of the OpenAPI document: v1alpha3 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +import re # noqa: F401 +from typing import Any, ClassVar + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing_extensions import Self + +from mr_openapi.models.artifact_state import ArtifactState +from mr_openapi.models.metadata_value import MetadataValue + + +class DocArtifactUpdate(BaseModel): + """A document artifact to be updated.""" # noqa: E501 + + custom_properties: dict[str, MetadataValue] | None = Field( + default=None, + description="User provided custom properties which are not defined by its type.", + alias="customProperties", + ) + description: StrictStr | None = Field(default=None, description="An optional description about the resource.") + external_id: StrictStr | None = Field( + default=None, + description="The external id that come from the clients’ system. This field is optional. If set, it must be unique among all resources within a database instance.", + alias="externalId", + ) + uri: StrictStr | None = Field( + default=None, + description="The uniform resource identifier of the physical artifact. May be empty if there is no physical artifact.", + ) + state: ArtifactState | None = None + artifact_type: StrictStr = Field(alias="artifactType") + __properties: ClassVar[list[str]] = [ + "customProperties", + "description", + "externalId", + "uri", + "state", + "artifactType", + ] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias.""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias.""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Self | None: + """Create an instance of DocArtifactUpdate from a JSON string.""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: set[str] = set() + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each value in custom_properties (dict) + _field_dict = {} + if self.custom_properties: + for _key in self.custom_properties: + if self.custom_properties[_key]: + _field_dict[_key] = self.custom_properties[_key].to_dict() + _dict["customProperties"] = _field_dict + return _dict + + @classmethod + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: + """Create an instance of DocArtifactUpdate from a dict.""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + return cls.model_validate( + { + "customProperties": ( + {_k: MetadataValue.from_dict(_v) for _k, _v in obj["customProperties"].items()} + if obj.get("customProperties") is not None + else None + ), + "description": obj.get("description"), + "externalId": obj.get("externalId"), + "uri": obj.get("uri"), + "state": obj.get("state"), + "artifactType": obj.get("artifactType") if obj.get("artifactType") is not None else "doc-artifact", + } + ) diff --git a/clients/python/src/mr_openapi/models/model_artifact.py b/clients/python/src/mr_openapi/models/model_artifact.py index 353aa88b..a9e0e48b 100644 --- a/clients/python/src/mr_openapi/models/model_artifact.py +++ b/clients/python/src/mr_openapi/models/model_artifact.py @@ -25,7 +25,6 @@ class ModelArtifact(BaseModel): """An ML model artifact.""" # noqa: E501 - artifact_type: StrictStr = Field(alias="artifactType") custom_properties: dict[str, MetadataValue] | None = Field( default=None, description="User provided custom properties which are not defined by its type.", @@ -57,6 +56,7 @@ class ModelArtifact(BaseModel): description="Output only. Last update time of the resource since epoch in millisecond since epoch.", alias="lastUpdateTimeSinceEpoch", ) + artifact_type: StrictStr = Field(alias="artifactType") model_format_name: StrictStr | None = Field( default=None, description="Name of the model format.", alias="modelFormatName" ) @@ -80,6 +80,7 @@ class ModelArtifact(BaseModel): "id", "createTimeSinceEpoch", "lastUpdateTimeSinceEpoch", + "artifactType", "modelFormatName", "storageKey", "storagePath", @@ -163,6 +164,7 @@ def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: "id": obj.get("id"), "createTimeSinceEpoch": obj.get("createTimeSinceEpoch"), "lastUpdateTimeSinceEpoch": obj.get("lastUpdateTimeSinceEpoch"), + "artifactType": obj.get("artifactType") if obj.get("artifactType") is not None else "model-artifact", "modelFormatName": obj.get("modelFormatName"), "storageKey": obj.get("storageKey"), "storagePath": obj.get("storagePath"), diff --git a/clients/python/src/mr_openapi/models/model_artifact_create.py b/clients/python/src/mr_openapi/models/model_artifact_create.py index bc5a34d7..a1bdfd99 100644 --- a/clients/python/src/mr_openapi/models/model_artifact_create.py +++ b/clients/python/src/mr_openapi/models/model_artifact_create.py @@ -45,6 +45,7 @@ class ModelArtifactCreate(BaseModel): default=None, description="The client provided name of the artifact. This field is optional. If set, it must be unique among all the artifacts of the same artifact type within a database instance and cannot be changed once set.", ) + artifact_type: StrictStr = Field(alias="artifactType") model_format_name: StrictStr | None = Field( default=None, description="Name of the model format.", alias="modelFormatName" ) @@ -65,6 +66,7 @@ class ModelArtifactCreate(BaseModel): "uri", "state", "name", + "artifactType", "modelFormatName", "storageKey", "storagePath", @@ -139,6 +141,7 @@ def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: "uri": obj.get("uri"), "state": obj.get("state"), "name": obj.get("name"), + "artifactType": obj.get("artifactType") if obj.get("artifactType") is not None else "model-artifact", "modelFormatName": obj.get("modelFormatName"), "storageKey": obj.get("storageKey"), "storagePath": obj.get("storagePath"), diff --git a/clients/python/src/mr_openapi/models/model_artifact_update.py b/clients/python/src/mr_openapi/models/model_artifact_update.py index 6df6896d..ff0ab582 100644 --- a/clients/python/src/mr_openapi/models/model_artifact_update.py +++ b/clients/python/src/mr_openapi/models/model_artifact_update.py @@ -23,7 +23,7 @@ class ModelArtifactUpdate(BaseModel): - """An ML model artifact.""" # noqa: E501 + """An ML model artifact to be updated.""" # noqa: E501 custom_properties: dict[str, MetadataValue] | None = Field( default=None, @@ -41,6 +41,7 @@ class ModelArtifactUpdate(BaseModel): description="The uniform resource identifier of the physical artifact. May be empty if there is no physical artifact.", ) state: ArtifactState | None = None + artifact_type: StrictStr = Field(alias="artifactType") model_format_name: StrictStr | None = Field( default=None, description="Name of the model format.", alias="modelFormatName" ) @@ -60,6 +61,7 @@ class ModelArtifactUpdate(BaseModel): "externalId", "uri", "state", + "artifactType", "modelFormatName", "storageKey", "storagePath", @@ -133,6 +135,7 @@ def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: "externalId": obj.get("externalId"), "uri": obj.get("uri"), "state": obj.get("state"), + "artifactType": obj.get("artifactType") if obj.get("artifactType") is not None else "model-artifact", "modelFormatName": obj.get("modelFormatName"), "storageKey": obj.get("storageKey"), "storagePath": obj.get("storagePath"), diff --git a/clients/python/src/mr_openapi/models/registered_model.py b/clients/python/src/mr_openapi/models/registered_model.py index 6ee032c9..9bbe6c85 100644 --- a/clients/python/src/mr_openapi/models/registered_model.py +++ b/clients/python/src/mr_openapi/models/registered_model.py @@ -37,7 +37,7 @@ class RegisteredModel(BaseModel): alias="externalId", ) name: StrictStr = Field( - description="The client provided name of the artifact. This field is optional. If set, it must be unique among all the artifacts of the same artifact type within a database instance and cannot be changed once set." + description="The client provided name of the model. It must be unique among all the RegisteredModels of the same type within a Model Registry instance and cannot be changed once set." ) id: StrictStr | None = Field(default=None, description="The unique server generated id of the resource.") create_time_since_epoch: StrictStr | None = Field( diff --git a/clients/python/src/mr_openapi/models/registered_model_create.py b/clients/python/src/mr_openapi/models/registered_model_create.py index 29515e51..037ab793 100644 --- a/clients/python/src/mr_openapi/models/registered_model_create.py +++ b/clients/python/src/mr_openapi/models/registered_model_create.py @@ -37,7 +37,7 @@ class RegisteredModelCreate(BaseModel): alias="externalId", ) name: StrictStr = Field( - description="The client provided name of the artifact. This field is optional. If set, it must be unique among all the artifacts of the same artifact type within a database instance and cannot be changed once set." + description="The client provided name of the model. It must be unique among all the RegisteredModels of the same type within a Model Registry instance and cannot be changed once set." ) owner: StrictStr | None = None state: RegisteredModelState | None = None diff --git a/internal/converter/generated/mlmd_openapi_converter.gen.go b/internal/converter/generated/mlmd_openapi_converter.gen.go index e140392c..5b42bd0d 100644 --- a/internal/converter/generated/mlmd_openapi_converter.gen.go +++ b/internal/converter/generated/mlmd_openapi_converter.gen.go @@ -16,11 +16,6 @@ func (c *MLMDToOpenAPIConverterImpl) ConvertDocArtifact(source *proto.Artifact) var pOpenapiDocArtifact *openapi.DocArtifact if source != nil { var openapiDocArtifact openapi.DocArtifact - xstring, err := converter.MapArtifactType(source) - if err != nil { - return nil, fmt.Errorf("error setting field ArtifactType: %w", err) - } - openapiDocArtifact.ArtifactType = xstring mapStringOpenapiMetadataValue, err := converter.MapMLMDCustomProperties((*source).CustomProperties) if err != nil { return nil, fmt.Errorf("error setting field CustomProperties: %w", err) @@ -28,18 +23,23 @@ func (c *MLMDToOpenAPIConverterImpl) ConvertDocArtifact(source *proto.Artifact) openapiDocArtifact.CustomProperties = &mapStringOpenapiMetadataValue openapiDocArtifact.Description = converter.MapDescription((*source).Properties) if (*source).ExternalId != nil { - xstring2 := *(*source).ExternalId - openapiDocArtifact.ExternalId = &xstring2 + xstring := *(*source).ExternalId + openapiDocArtifact.ExternalId = &xstring } if (*source).Uri != nil { - xstring3 := *(*source).Uri - openapiDocArtifact.Uri = &xstring3 + xstring2 := *(*source).Uri + openapiDocArtifact.Uri = &xstring2 } openapiDocArtifact.State = converter.MapMLMDArtifactState((*source).State) openapiDocArtifact.Name = converter.MapNameFromOwned((*source).Name) openapiDocArtifact.Id = converter.Int64ToString((*source).Id) openapiDocArtifact.CreateTimeSinceEpoch = converter.Int64ToString((*source).CreateTimeSinceEpoch) openapiDocArtifact.LastUpdateTimeSinceEpoch = converter.Int64ToString((*source).LastUpdateTimeSinceEpoch) + xstring3, err := converter.MapArtifactType(source) + if err != nil { + return nil, fmt.Errorf("error setting field ArtifactType: %w", err) + } + openapiDocArtifact.ArtifactType = xstring3 pOpenapiDocArtifact = &openapiDocArtifact } return pOpenapiDocArtifact, nil @@ -75,11 +75,6 @@ func (c *MLMDToOpenAPIConverterImpl) ConvertModelArtifact(source *proto.Artifact var pOpenapiModelArtifact *openapi.ModelArtifact if source != nil { var openapiModelArtifact openapi.ModelArtifact - xstring, err := converter.MapArtifactType(source) - if err != nil { - return nil, fmt.Errorf("error setting field ArtifactType: %w", err) - } - openapiModelArtifact.ArtifactType = xstring mapStringOpenapiMetadataValue, err := converter.MapMLMDCustomProperties((*source).CustomProperties) if err != nil { return nil, fmt.Errorf("error setting field CustomProperties: %w", err) @@ -87,18 +82,23 @@ func (c *MLMDToOpenAPIConverterImpl) ConvertModelArtifact(source *proto.Artifact openapiModelArtifact.CustomProperties = &mapStringOpenapiMetadataValue openapiModelArtifact.Description = converter.MapDescription((*source).Properties) if (*source).ExternalId != nil { - xstring2 := *(*source).ExternalId - openapiModelArtifact.ExternalId = &xstring2 + xstring := *(*source).ExternalId + openapiModelArtifact.ExternalId = &xstring } if (*source).Uri != nil { - xstring3 := *(*source).Uri - openapiModelArtifact.Uri = &xstring3 + xstring2 := *(*source).Uri + openapiModelArtifact.Uri = &xstring2 } openapiModelArtifact.State = converter.MapMLMDArtifactState((*source).State) openapiModelArtifact.Name = converter.MapNameFromOwned((*source).Name) openapiModelArtifact.Id = converter.Int64ToString((*source).Id) openapiModelArtifact.CreateTimeSinceEpoch = converter.Int64ToString((*source).CreateTimeSinceEpoch) openapiModelArtifact.LastUpdateTimeSinceEpoch = converter.Int64ToString((*source).LastUpdateTimeSinceEpoch) + xstring3, err := converter.MapArtifactType(source) + if err != nil { + return nil, fmt.Errorf("error setting field ArtifactType: %w", err) + } + openapiModelArtifact.ArtifactType = xstring3 openapiModelArtifact.ModelFormatName = converter.MapModelArtifactFormatName((*source).Properties) openapiModelArtifact.StorageKey = converter.MapModelArtifactStorageKey((*source).Properties) openapiModelArtifact.StoragePath = converter.MapModelArtifactStoragePath((*source).Properties) diff --git a/internal/converter/generated/openapi_converter.gen.go b/internal/converter/generated/openapi_converter.gen.go index 7d1c8c14..24d1ba49 100644 --- a/internal/converter/generated/openapi_converter.gen.go +++ b/internal/converter/generated/openapi_converter.gen.go @@ -11,6 +11,120 @@ import ( type OpenAPIConverterImpl struct{} +func (c *OpenAPIConverterImpl) ConvertArtifactCreate(source *openapi.ArtifactCreate) (*openapi.Artifact, error) { + var pOpenapiArtifact *openapi.Artifact + if source != nil { + var openapiArtifact openapi.Artifact + pOpenapiDocArtifact, err := c.ConvertDocArtifactCreate((*source).DocArtifactCreate) + if err != nil { + return nil, fmt.Errorf("error setting field DocArtifact: %w", err) + } + openapiArtifact.DocArtifact = pOpenapiDocArtifact + pOpenapiModelArtifact, err := c.ConvertModelArtifactCreate((*source).ModelArtifactCreate) + if err != nil { + return nil, fmt.Errorf("error setting field ModelArtifact: %w", err) + } + openapiArtifact.ModelArtifact = pOpenapiModelArtifact + pOpenapiArtifact = &openapiArtifact + } + return pOpenapiArtifact, nil +} +func (c *OpenAPIConverterImpl) ConvertArtifactUpdate(source *openapi.ArtifactUpdate) (*openapi.Artifact, error) { + var pOpenapiArtifact *openapi.Artifact + if source != nil { + var openapiArtifact openapi.Artifact + pOpenapiDocArtifact, err := c.ConvertDocArtifactUpdate((*source).DocArtifactUpdate) + if err != nil { + return nil, fmt.Errorf("error setting field DocArtifact: %w", err) + } + openapiArtifact.DocArtifact = pOpenapiDocArtifact + pOpenapiModelArtifact, err := c.ConvertModelArtifactUpdate((*source).ModelArtifactUpdate) + if err != nil { + return nil, fmt.Errorf("error setting field ModelArtifact: %w", err) + } + openapiArtifact.ModelArtifact = pOpenapiModelArtifact + pOpenapiArtifact = &openapiArtifact + } + return pOpenapiArtifact, nil +} +func (c *OpenAPIConverterImpl) ConvertDocArtifactCreate(source *openapi.DocArtifactCreate) (*openapi.DocArtifact, error) { + var pOpenapiDocArtifact *openapi.DocArtifact + if source != nil { + var openapiDocArtifact openapi.DocArtifact + if (*source).CustomProperties != nil { + var mapStringOpenapiMetadataValue map[string]openapi.MetadataValue + if (*(*source).CustomProperties) != nil { + mapStringOpenapiMetadataValue = make(map[string]openapi.MetadataValue, len((*(*source).CustomProperties))) + for key, value := range *(*source).CustomProperties { + mapStringOpenapiMetadataValue[key] = c.openapiMetadataValueToOpenapiMetadataValue(value) + } + } + openapiDocArtifact.CustomProperties = &mapStringOpenapiMetadataValue + } + if (*source).Description != nil { + xstring := *(*source).Description + openapiDocArtifact.Description = &xstring + } + if (*source).ExternalId != nil { + xstring2 := *(*source).ExternalId + openapiDocArtifact.ExternalId = &xstring2 + } + if (*source).Uri != nil { + xstring3 := *(*source).Uri + openapiDocArtifact.Uri = &xstring3 + } + if (*source).State != nil { + openapiArtifactState, err := c.openapiArtifactStateToOpenapiArtifactState(*(*source).State) + if err != nil { + return nil, fmt.Errorf("error setting field State: %w", err) + } + openapiDocArtifact.State = &openapiArtifactState + } + if (*source).Name != nil { + xstring4 := *(*source).Name + openapiDocArtifact.Name = &xstring4 + } + pOpenapiDocArtifact = &openapiDocArtifact + } + return pOpenapiDocArtifact, nil +} +func (c *OpenAPIConverterImpl) ConvertDocArtifactUpdate(source *openapi.DocArtifactUpdate) (*openapi.DocArtifact, error) { + var pOpenapiDocArtifact *openapi.DocArtifact + if source != nil { + var openapiDocArtifact openapi.DocArtifact + if (*source).CustomProperties != nil { + var mapStringOpenapiMetadataValue map[string]openapi.MetadataValue + if (*(*source).CustomProperties) != nil { + mapStringOpenapiMetadataValue = make(map[string]openapi.MetadataValue, len((*(*source).CustomProperties))) + for key, value := range *(*source).CustomProperties { + mapStringOpenapiMetadataValue[key] = c.openapiMetadataValueToOpenapiMetadataValue(value) + } + } + openapiDocArtifact.CustomProperties = &mapStringOpenapiMetadataValue + } + if (*source).Description != nil { + xstring := *(*source).Description + openapiDocArtifact.Description = &xstring + } + if (*source).ExternalId != nil { + xstring2 := *(*source).ExternalId + openapiDocArtifact.ExternalId = &xstring2 + } + if (*source).Uri != nil { + xstring3 := *(*source).Uri + openapiDocArtifact.Uri = &xstring3 + } + if (*source).State != nil { + openapiArtifactState, err := c.openapiArtifactStateToOpenapiArtifactState(*(*source).State) + if err != nil { + return nil, fmt.Errorf("error setting field State: %w", err) + } + openapiDocArtifact.State = &openapiArtifactState + } + pOpenapiDocArtifact = &openapiDocArtifact + } + return pOpenapiDocArtifact, nil +} func (c *OpenAPIConverterImpl) ConvertInferenceServiceCreate(source *openapi.InferenceServiceCreate) (*openapi.InferenceService, error) { var pOpenapiInferenceService *openapi.InferenceService if source != nil { @@ -495,6 +609,11 @@ func (c *OpenAPIConverterImpl) ConvertServingEnvironmentUpdate(source *openapi.S } return pOpenapiServingEnvironment, nil } +func (c *OpenAPIConverterImpl) OverrideNotEditableForArtifact(source converter.OpenapiUpdateWrapper[openapi.Artifact]) (openapi.Artifact, error) { + openapiArtifact := converter.InitWithUpdate(source) + _ = source + return openapiArtifact, nil +} func (c *OpenAPIConverterImpl) OverrideNotEditableForDocArtifact(source converter.OpenapiUpdateWrapper[openapi.DocArtifact]) (openapi.DocArtifact, error) { openapiDocArtifact := converter.InitWithUpdate(source) _ = source @@ -530,18 +649,18 @@ func (c *OpenAPIConverterImpl) OverrideNotEditableForModelArtifact(source conver openapiModelArtifact := converter.InitWithUpdate(source) var pString *string if source.Existing != nil { - pString = &source.Existing.ArtifactType + pString = source.Existing.Name } if pString != nil { - openapiModelArtifact.ArtifactType = *pString + xstring := *pString + openapiModelArtifact.Name = &xstring } var pString2 *string if source.Existing != nil { - pString2 = source.Existing.Name + pString2 = &source.Existing.ArtifactType } if pString2 != nil { - xstring := *pString2 - openapiModelArtifact.Name = &xstring + openapiModelArtifact.ArtifactType = *pString2 } return openapiModelArtifact, nil } diff --git a/internal/converter/generated/openapi_reconciler.gen.go b/internal/converter/generated/openapi_reconciler.gen.go index fcfccce9..13497b14 100644 --- a/internal/converter/generated/openapi_reconciler.gen.go +++ b/internal/converter/generated/openapi_reconciler.gen.go @@ -11,6 +11,28 @@ import ( type OpenAPIReconcilerImpl struct{} +func (c *OpenAPIReconcilerImpl) UpdateExistingArtifact(source converter.OpenapiUpdateWrapper[openapi.Artifact]) (openapi.Artifact, error) { + openapiArtifact := converter.InitWithExisting(source) + var pOpenapiDocArtifact *openapi.DocArtifact + if source.Update != nil { + pOpenapiDocArtifact = source.Update.DocArtifact + } + pOpenapiDocArtifact2, err := c.pOpenapiDocArtifactToPOpenapiDocArtifact(pOpenapiDocArtifact) + if err != nil { + return openapiArtifact, fmt.Errorf("error setting field DocArtifact: %w", err) + } + openapiArtifact.DocArtifact = pOpenapiDocArtifact2 + var pOpenapiModelArtifact *openapi.ModelArtifact + if source.Update != nil { + pOpenapiModelArtifact = source.Update.ModelArtifact + } + pOpenapiModelArtifact2, err := c.pOpenapiModelArtifactToPOpenapiModelArtifact(pOpenapiModelArtifact) + if err != nil { + return openapiArtifact, fmt.Errorf("error setting field ModelArtifact: %w", err) + } + openapiArtifact.ModelArtifact = pOpenapiModelArtifact2 + return openapiArtifact, nil +} func (c *OpenAPIReconcilerImpl) UpdateExistingDocArtifact(source converter.OpenapiUpdateWrapper[openapi.DocArtifact]) (openapi.DocArtifact, error) { openapiDocArtifact := converter.InitWithExisting(source) var pMapStringOpenapiMetadataValue *map[string]openapi.MetadataValue @@ -493,6 +515,60 @@ func (c *OpenAPIReconcilerImpl) openapiRegisteredModelStateToOpenapiRegisteredMo } return openapiRegisteredModelState, nil } +func (c *OpenAPIReconcilerImpl) pOpenapiDocArtifactToPOpenapiDocArtifact(source *openapi.DocArtifact) (*openapi.DocArtifact, error) { + var pOpenapiDocArtifact *openapi.DocArtifact + if source != nil { + var openapiDocArtifact openapi.DocArtifact + if (*source).CustomProperties != nil { + var mapStringOpenapiMetadataValue map[string]openapi.MetadataValue + if (*(*source).CustomProperties) != nil { + mapStringOpenapiMetadataValue = make(map[string]openapi.MetadataValue, len((*(*source).CustomProperties))) + for key, value := range *(*source).CustomProperties { + mapStringOpenapiMetadataValue[key] = c.openapiMetadataValueToOpenapiMetadataValue(value) + } + } + openapiDocArtifact.CustomProperties = &mapStringOpenapiMetadataValue + } + if (*source).Description != nil { + xstring := *(*source).Description + openapiDocArtifact.Description = &xstring + } + if (*source).ExternalId != nil { + xstring2 := *(*source).ExternalId + openapiDocArtifact.ExternalId = &xstring2 + } + if (*source).Uri != nil { + xstring3 := *(*source).Uri + openapiDocArtifact.Uri = &xstring3 + } + if (*source).State != nil { + openapiArtifactState, err := c.openapiArtifactStateToOpenapiArtifactState(*(*source).State) + if err != nil { + return nil, fmt.Errorf("error setting field State: %w", err) + } + openapiDocArtifact.State = &openapiArtifactState + } + if (*source).Name != nil { + xstring4 := *(*source).Name + openapiDocArtifact.Name = &xstring4 + } + if (*source).Id != nil { + xstring5 := *(*source).Id + openapiDocArtifact.Id = &xstring5 + } + if (*source).CreateTimeSinceEpoch != nil { + xstring6 := *(*source).CreateTimeSinceEpoch + openapiDocArtifact.CreateTimeSinceEpoch = &xstring6 + } + if (*source).LastUpdateTimeSinceEpoch != nil { + xstring7 := *(*source).LastUpdateTimeSinceEpoch + openapiDocArtifact.LastUpdateTimeSinceEpoch = &xstring7 + } + openapiDocArtifact.ArtifactType = (*source).ArtifactType + pOpenapiDocArtifact = &openapiDocArtifact + } + return pOpenapiDocArtifact, nil +} func (c *OpenAPIReconcilerImpl) pOpenapiMetadataBoolValueToPOpenapiMetadataBoolValue(source *openapi.MetadataBoolValue) *openapi.MetadataBoolValue { var pOpenapiMetadataBoolValue *openapi.MetadataBoolValue if source != nil { @@ -554,3 +630,77 @@ func (c *OpenAPIReconcilerImpl) pOpenapiMetadataStructValueToPOpenapiMetadataStr } return pOpenapiMetadataStructValue } +func (c *OpenAPIReconcilerImpl) pOpenapiModelArtifactToPOpenapiModelArtifact(source *openapi.ModelArtifact) (*openapi.ModelArtifact, error) { + var pOpenapiModelArtifact *openapi.ModelArtifact + if source != nil { + var openapiModelArtifact openapi.ModelArtifact + if (*source).CustomProperties != nil { + var mapStringOpenapiMetadataValue map[string]openapi.MetadataValue + if (*(*source).CustomProperties) != nil { + mapStringOpenapiMetadataValue = make(map[string]openapi.MetadataValue, len((*(*source).CustomProperties))) + for key, value := range *(*source).CustomProperties { + mapStringOpenapiMetadataValue[key] = c.openapiMetadataValueToOpenapiMetadataValue(value) + } + } + openapiModelArtifact.CustomProperties = &mapStringOpenapiMetadataValue + } + if (*source).Description != nil { + xstring := *(*source).Description + openapiModelArtifact.Description = &xstring + } + if (*source).ExternalId != nil { + xstring2 := *(*source).ExternalId + openapiModelArtifact.ExternalId = &xstring2 + } + if (*source).Uri != nil { + xstring3 := *(*source).Uri + openapiModelArtifact.Uri = &xstring3 + } + if (*source).State != nil { + openapiArtifactState, err := c.openapiArtifactStateToOpenapiArtifactState(*(*source).State) + if err != nil { + return nil, fmt.Errorf("error setting field State: %w", err) + } + openapiModelArtifact.State = &openapiArtifactState + } + if (*source).Name != nil { + xstring4 := *(*source).Name + openapiModelArtifact.Name = &xstring4 + } + if (*source).Id != nil { + xstring5 := *(*source).Id + openapiModelArtifact.Id = &xstring5 + } + if (*source).CreateTimeSinceEpoch != nil { + xstring6 := *(*source).CreateTimeSinceEpoch + openapiModelArtifact.CreateTimeSinceEpoch = &xstring6 + } + if (*source).LastUpdateTimeSinceEpoch != nil { + xstring7 := *(*source).LastUpdateTimeSinceEpoch + openapiModelArtifact.LastUpdateTimeSinceEpoch = &xstring7 + } + openapiModelArtifact.ArtifactType = (*source).ArtifactType + if (*source).ModelFormatName != nil { + xstring8 := *(*source).ModelFormatName + openapiModelArtifact.ModelFormatName = &xstring8 + } + if (*source).StorageKey != nil { + xstring9 := *(*source).StorageKey + openapiModelArtifact.StorageKey = &xstring9 + } + if (*source).StoragePath != nil { + xstring10 := *(*source).StoragePath + openapiModelArtifact.StoragePath = &xstring10 + } + if (*source).ModelFormatVersion != nil { + xstring11 := *(*source).ModelFormatVersion + openapiModelArtifact.ModelFormatVersion = &xstring11 + } + if (*source).ServiceAccountName != nil { + xstring12 := *(*source).ServiceAccountName + openapiModelArtifact.ServiceAccountName = &xstring12 + } + pOpenapiModelArtifact = &openapiModelArtifact + } + return pOpenapiModelArtifact, nil +} diff --git a/internal/converter/openapi_converter.go b/internal/converter/openapi_converter.go index 60a4c41d..df704ddd 100644 --- a/internal/converter/openapi_converter.go +++ b/internal/converter/openapi_converter.go @@ -26,6 +26,20 @@ type OpenAPIConverter interface { // goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch Name RegisteredModelId ConvertModelVersionUpdate(source *openapi.ModelVersionUpdate) (*openapi.ModelVersion, error) + // goverter:map DocArtifactCreate DocArtifact + // goverter:map ModelArtifactCreate ModelArtifact + ConvertArtifactCreate(source *openapi.ArtifactCreate) (*openapi.Artifact, error) + + // goverter:map DocArtifactUpdate DocArtifact + // goverter:map ModelArtifactUpdate ModelArtifact + ConvertArtifactUpdate(source *openapi.ArtifactUpdate) (*openapi.Artifact, error) + + // goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch ArtifactType + ConvertDocArtifactCreate(source *openapi.DocArtifactCreate) (*openapi.DocArtifact, error) + + // goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch ArtifactType Name + ConvertDocArtifactUpdate(source *openapi.DocArtifactUpdate) (*openapi.DocArtifact, error) + // goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch ArtifactType ConvertModelArtifactCreate(source *openapi.ModelArtifactCreate) (*openapi.ModelArtifact, error) @@ -62,6 +76,12 @@ type OpenAPIConverter interface { // goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch Description ExternalId CustomProperties State Author OverrideNotEditableForModelVersion(source OpenapiUpdateWrapper[openapi.ModelVersion]) (openapi.ModelVersion, error) + // Ignore all fields that ARE editable + // goverter:default InitWithUpdate + // goverter:autoMap Existing + // goverter:ignore DocArtifact ModelArtifact + OverrideNotEditableForArtifact(source OpenapiUpdateWrapper[openapi.Artifact]) (openapi.Artifact, error) + // Ignore all fields that ARE editable // goverter:default InitWithUpdate // goverter:autoMap Existing diff --git a/internal/converter/openapi_converter_test.go b/internal/converter/openapi_converter_test.go index 4c33c27e..e9869e11 100644 --- a/internal/converter/openapi_converter_test.go +++ b/internal/converter/openapi_converter_test.go @@ -20,7 +20,7 @@ type visitor struct { entities map[string]*oapiEntity } -func newVisitor(t *testing.T, f *ast.File) visitor { +func newVisitor(t *testing.T, _ *ast.File) visitor { return visitor{ t: t, entities: map[string]*oapiEntity{ @@ -45,6 +45,9 @@ func newVisitor(t *testing.T, f *ast.File) visitor { "ServeModel": { obj: openapi.ServeModel{}, }, + "Artifact": { + obj: openapi.Artifact{}, + }, }, } } diff --git a/internal/converter/openapi_converter_util.go b/internal/converter/openapi_converter_util.go index 816fe111..b7a8964f 100644 --- a/internal/converter/openapi_converter_util.go +++ b/internal/converter/openapi_converter_util.go @@ -3,7 +3,8 @@ package converter import "github.com/kubeflow/model-registry/pkg/openapi" type OpenAPIModel interface { - openapi.RegisteredModel | + openapi.Artifact | + openapi.RegisteredModel | openapi.ModelVersion | openapi.ModelArtifact | openapi.DocArtifact | diff --git a/internal/converter/openapi_reconciler.go b/internal/converter/openapi_reconciler.go index 47cd3395..d6717015 100644 --- a/internal/converter/openapi_reconciler.go +++ b/internal/converter/openapi_reconciler.go @@ -24,6 +24,11 @@ type OpenAPIReconciler interface { // goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch Name RegisteredModelId UpdateExistingModelVersion(source OpenapiUpdateWrapper[openapi.ModelVersion]) (openapi.ModelVersion, error) + // Ignore all fields that can't be updated + // goverter:default InitWithExisting + // goverter:autoMap Update + UpdateExistingArtifact(source OpenapiUpdateWrapper[openapi.Artifact]) (openapi.Artifact, error) + // Ignore all fields that can't be updated // goverter:default InitWithExisting // goverter:autoMap Update diff --git a/internal/server/openapi/api.go b/internal/server/openapi/api.go index c62155d2..cc6be125 100644 --- a/internal/server/openapi/api.go +++ b/internal/server/openapi/api.go @@ -65,12 +65,14 @@ type ModelRegistryServiceAPIServicer interface { CreateEnvironmentInferenceService(context.Context, string, model.InferenceServiceCreate) (ImplResponse, error) CreateInferenceService(context.Context, model.InferenceServiceCreate) (ImplResponse, error) CreateInferenceServiceServe(context.Context, string, model.ServeModelCreate) (ImplResponse, error) + CreateArtifact(context.Context, model.ArtifactCreate) (ImplResponse, error) CreateModelArtifact(context.Context, model.ModelArtifactCreate) (ImplResponse, error) CreateModelVersion(context.Context, model.ModelVersionCreate) (ImplResponse, error) CreateRegisteredModel(context.Context, model.RegisteredModelCreate) (ImplResponse, error) CreateRegisteredModelVersion(context.Context, string, model.ModelVersion) (ImplResponse, error) CreateServingEnvironment(context.Context, model.ServingEnvironmentCreate) (ImplResponse, error) FindInferenceService(context.Context, string, string, string) (ImplResponse, error) + FindArtifact(context.Context, string, string, string) (ImplResponse, error) FindModelArtifact(context.Context, string, string, string) (ImplResponse, error) FindModelVersion(context.Context, string, string, string) (ImplResponse, error) FindRegisteredModel(context.Context, string, string) (ImplResponse, error) @@ -81,6 +83,8 @@ type ModelRegistryServiceAPIServicer interface { GetInferenceServiceServes(context.Context, string, string, string, string, model.OrderByField, model.SortOrder, string) (ImplResponse, error) GetInferenceServiceVersion(context.Context, string) (ImplResponse, error) GetInferenceServices(context.Context, string, model.OrderByField, model.SortOrder, string) (ImplResponse, error) + GetArtifact(context.Context, string) (ImplResponse, error) + GetArtifacts(context.Context, string, model.OrderByField, model.SortOrder, string) (ImplResponse, error) GetModelArtifact(context.Context, string) (ImplResponse, error) GetModelArtifacts(context.Context, string, model.OrderByField, model.SortOrder, string) (ImplResponse, error) GetModelVersion(context.Context, string) (ImplResponse, error) @@ -92,6 +96,7 @@ type ModelRegistryServiceAPIServicer interface { GetServingEnvironment(context.Context, string) (ImplResponse, error) GetServingEnvironments(context.Context, string, model.OrderByField, model.SortOrder, string) (ImplResponse, error) UpdateInferenceService(context.Context, string, model.InferenceServiceUpdate) (ImplResponse, error) + UpdateArtifact(context.Context, string, model.ArtifactUpdate) (ImplResponse, error) UpdateModelArtifact(context.Context, string, model.ModelArtifactUpdate) (ImplResponse, error) UpdateModelVersion(context.Context, string, model.ModelVersionUpdate) (ImplResponse, error) UpdateRegisteredModel(context.Context, string, model.RegisteredModelUpdate) (ImplResponse, error) diff --git a/internal/server/openapi/api_model_registry_service.go b/internal/server/openapi/api_model_registry_service.go index e4134e30..58448254 100644 --- a/internal/server/openapi/api_model_registry_service.go +++ b/internal/server/openapi/api_model_registry_service.go @@ -52,6 +52,11 @@ func NewModelRegistryServiceAPIController(s ModelRegistryServiceAPIServicer, opt // Routes returns all the api routes for the ModelRegistryServiceAPIController func (c *ModelRegistryServiceAPIController) Routes() Routes { return Routes{ + "CreateArtifact": Route{ + strings.ToUpper("Post"), + "/api/model_registry/v1alpha3/artifacts", + c.CreateArtifact, + }, "CreateEnvironmentInferenceService": Route{ strings.ToUpper("Post"), "/api/model_registry/v1alpha3/serving_environments/{servingenvironmentId}/inference_services", @@ -92,6 +97,11 @@ func (c *ModelRegistryServiceAPIController) Routes() Routes { "/api/model_registry/v1alpha3/serving_environments", c.CreateServingEnvironment, }, + "FindArtifact": Route{ + strings.ToUpper("Get"), + "/api/model_registry/v1alpha3/artifact", + c.FindArtifact, + }, "FindInferenceService": Route{ strings.ToUpper("Get"), "/api/model_registry/v1alpha3/inference_service", @@ -117,6 +127,16 @@ func (c *ModelRegistryServiceAPIController) Routes() Routes { "/api/model_registry/v1alpha3/serving_environment", c.FindServingEnvironment, }, + "GetArtifact": Route{ + strings.ToUpper("Get"), + "/api/model_registry/v1alpha3/artifacts/{id}", + c.GetArtifact, + }, + "GetArtifacts": Route{ + strings.ToUpper("Get"), + "/api/model_registry/v1alpha3/artifacts", + c.GetArtifacts, + }, "GetEnvironmentInferenceServices": Route{ strings.ToUpper("Get"), "/api/model_registry/v1alpha3/serving_environments/{servingenvironmentId}/inference_services", @@ -197,6 +217,11 @@ func (c *ModelRegistryServiceAPIController) Routes() Routes { "/api/model_registry/v1alpha3/serving_environments", c.GetServingEnvironments, }, + "UpdateArtifact": Route{ + strings.ToUpper("Patch"), + "/api/model_registry/v1alpha3/artifacts/{id}", + c.UpdateArtifact, + }, "UpdateInferenceService": Route{ strings.ToUpper("Patch"), "/api/model_registry/v1alpha3/inference_services/{inferenceserviceId}", @@ -230,6 +255,33 @@ func (c *ModelRegistryServiceAPIController) Routes() Routes { } } +// CreateArtifact - Create an Artifact +func (c *ModelRegistryServiceAPIController) CreateArtifact(w http.ResponseWriter, r *http.Request) { + artifactCreateParam := model.ArtifactCreate{} + d := json.NewDecoder(r.Body) + d.DisallowUnknownFields() + if err := d.Decode(&artifactCreateParam); err != nil { + c.errorHandler(w, r, &ParsingError{Err: err}, nil) + return + } + if err := AssertArtifactCreateRequired(artifactCreateParam); err != nil { + c.errorHandler(w, r, err, nil) + return + } + if err := AssertArtifactCreateConstraints(artifactCreateParam); err != nil { + c.errorHandler(w, r, err, nil) + return + } + result, err := c.service.CreateArtifact(r.Context(), artifactCreateParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) +} + // CreateEnvironmentInferenceService - Create a InferenceService in ServingEnvironment func (c *ModelRegistryServiceAPIController) CreateEnvironmentInferenceService(w http.ResponseWriter, r *http.Request) { servingenvironmentIdParam := chi.URLParam(r, "servingenvironmentId") @@ -449,6 +501,22 @@ func (c *ModelRegistryServiceAPIController) CreateServingEnvironment(w http.Resp EncodeJSONResponse(result.Body, &result.Code, w) } +// FindArtifact - Get an Artifact that matches search parameters. +func (c *ModelRegistryServiceAPIController) FindArtifact(w http.ResponseWriter, r *http.Request) { + query := r.URL.Query() + nameParam := query.Get("name") + externalIdParam := query.Get("externalId") + parentResourceIdParam := query.Get("parentResourceId") + result, err := c.service.FindArtifact(r.Context(), nameParam, externalIdParam, parentResourceIdParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) +} + // FindInferenceService - Get an InferenceServices that matches search parameters. func (c *ModelRegistryServiceAPIController) FindInferenceService(w http.ResponseWriter, r *http.Request) { query := r.URL.Query() @@ -527,6 +595,36 @@ func (c *ModelRegistryServiceAPIController) FindServingEnvironment(w http.Respon EncodeJSONResponse(result.Body, &result.Code, w) } +// GetArtifact - Get an Artifact +func (c *ModelRegistryServiceAPIController) GetArtifact(w http.ResponseWriter, r *http.Request) { + idParam := chi.URLParam(r, "id") + result, err := c.service.GetArtifact(r.Context(), idParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) +} + +// GetArtifacts - List All Artifacts +func (c *ModelRegistryServiceAPIController) GetArtifacts(w http.ResponseWriter, r *http.Request) { + query := r.URL.Query() + pageSizeParam := query.Get("pageSize") + orderByParam := query.Get("orderBy") + sortOrderParam := query.Get("sortOrder") + nextPageTokenParam := query.Get("nextPageToken") + result, err := c.service.GetArtifacts(r.Context(), pageSizeParam, model.OrderByField(orderByParam), model.SortOrder(sortOrderParam), nextPageTokenParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) +} + // GetEnvironmentInferenceServices - List All ServingEnvironment's InferenceServices func (c *ModelRegistryServiceAPIController) GetEnvironmentInferenceServices(w http.ResponseWriter, r *http.Request) { query := r.URL.Query() @@ -783,6 +881,34 @@ func (c *ModelRegistryServiceAPIController) GetServingEnvironments(w http.Respon EncodeJSONResponse(result.Body, &result.Code, w) } +// UpdateArtifact - Update an Artifact +func (c *ModelRegistryServiceAPIController) UpdateArtifact(w http.ResponseWriter, r *http.Request) { + idParam := chi.URLParam(r, "id") + artifactUpdateParam := model.ArtifactUpdate{} + d := json.NewDecoder(r.Body) + d.DisallowUnknownFields() + if err := d.Decode(&artifactUpdateParam); err != nil { + c.errorHandler(w, r, &ParsingError{Err: err}, nil) + return + } + if err := AssertArtifactUpdateRequired(artifactUpdateParam); err != nil { + c.errorHandler(w, r, err, nil) + return + } + if err := AssertArtifactUpdateConstraints(artifactUpdateParam); err != nil { + c.errorHandler(w, r, err, nil) + return + } + result, err := c.service.UpdateArtifact(r.Context(), idParam, artifactUpdateParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) +} + // UpdateInferenceService - Update a InferenceService func (c *ModelRegistryServiceAPIController) UpdateInferenceService(w http.ResponseWriter, r *http.Request) { inferenceserviceIdParam := chi.URLParam(r, "inferenceserviceId") diff --git a/internal/server/openapi/api_model_registry_service_service.go b/internal/server/openapi/api_model_registry_service_service.go index c0d0e6bd..cc4c239b 100644 --- a/internal/server/openapi/api_model_registry_service_service.go +++ b/internal/server/openapi/api_model_registry_service_service.go @@ -75,6 +75,21 @@ func (s *ModelRegistryServiceAPIService) CreateInferenceServiceServe(ctx context // TODO: return Response(http.StatusUnauthorized, Error{}), nil } +// CreateArtifact - Create an Artifact +func (s *ModelRegistryServiceAPIService) CreateArtifact(ctx context.Context, artifactCreate model.ArtifactCreate) (ImplResponse, error) { + entity, err := s.converter.ConvertArtifactCreate(&artifactCreate) + if err != nil { + return ErrorResponse(http.StatusBadRequest, err), err + } + + result, err := s.coreApi.UpsertArtifact(entity) + if err != nil { + return ErrorResponse(api.ErrToStatus(err), err), err + } + return Response(http.StatusCreated, result), nil + // TODO: return Response(http.StatusUnauthorized, Error{}), nil +} + // CreateModelArtifact - Create a ModelArtifact func (s *ModelRegistryServiceAPIService) CreateModelArtifact(ctx context.Context, modelArtifactCreate model.ModelArtifactCreate) (ImplResponse, error) { entity, err := s.converter.ConvertModelArtifactCreate(&modelArtifactCreate) @@ -172,6 +187,16 @@ func (s *ModelRegistryServiceAPIService) FindInferenceService(ctx context.Contex // TODO return Response(http.StatusUnauthorized, Error{}), nil } +// FindArtifact - Get an Artifact that matches search parameters. +func (s *ModelRegistryServiceAPIService) FindArtifact(ctx context.Context, name string, externalId string, parentResourceId string) (ImplResponse, error) { + result, err := s.coreApi.GetArtifactByParams(apiutils.StrPtr(name), apiutils.StrPtr(parentResourceId), apiutils.StrPtr(externalId)) + if err != nil { + return ErrorResponse(api.ErrToStatus(err), err), err + } + return Response(http.StatusOK, result), nil + // TODO return Response(http.StatusUnauthorized, Error{}), nil +} + // FindModelArtifact - Get a ModelArtifact that matches search parameters. func (s *ModelRegistryServiceAPIService) FindModelArtifact(ctx context.Context, name string, externalId string, parentResourceId string) (ImplResponse, error) { result, err := s.coreApi.GetModelArtifactByParams(apiutils.StrPtr(name), apiutils.StrPtr(parentResourceId), apiutils.StrPtr(externalId)) @@ -284,6 +309,30 @@ func (s *ModelRegistryServiceAPIService) GetInferenceServices(ctx context.Contex // TODO return Response(http.StatusUnauthorized, Error{}), nil } +// GetArtifact - Get a Artifact +func (s *ModelRegistryServiceAPIService) GetArtifact(ctx context.Context, artifactId string) (ImplResponse, error) { + result, err := s.coreApi.GetArtifactById(artifactId) + if err != nil { + return ErrorResponse(api.ErrToStatus(err), err), err + } + return Response(http.StatusOK, result), nil + // TODO: return Response(http.StatusUnauthorized, Error{}), nil +} + +// GetArtifacts - List All Artifacts +func (s *ModelRegistryServiceAPIService) GetArtifacts(ctx context.Context, pageSize string, orderBy model.OrderByField, sortOrder model.SortOrder, nextPageToken string) (ImplResponse, error) { + listOpts, err := apiutils.BuildListOption(pageSize, orderBy, sortOrder, nextPageToken) + if err != nil { + return ErrorResponse(api.ErrToStatus(err), err), err + } + result, err := s.coreApi.GetArtifacts(listOpts, nil) + if err != nil { + return ErrorResponse(api.ErrToStatus(err), err), err + } + return Response(http.StatusOK, result), nil + // TODO return Response(http.StatusUnauthorized, Error{}), nil +} + // GetModelArtifact - Get a ModelArtifact func (s *ModelRegistryServiceAPIService) GetModelArtifact(ctx context.Context, modelartifactId string) (ImplResponse, error) { result, err := s.coreApi.GetModelArtifactById(modelartifactId) @@ -435,6 +484,33 @@ func (s *ModelRegistryServiceAPIService) UpdateInferenceService(ctx context.Cont // TODO return Response(http.StatusUnauthorized, Error{}), nil } +// UpdateArtifact - Update a Artifact +func (s *ModelRegistryServiceAPIService) UpdateArtifact(ctx context.Context, artifactId string, artifactUpdate model.ArtifactUpdate) (ImplResponse, error) { + entity, err := s.converter.ConvertArtifactUpdate(&artifactUpdate) + if err != nil { + return ErrorResponse(http.StatusBadRequest, err), err + } + if artifactUpdate.DocArtifactUpdate != nil { + entity.DocArtifact.Id = &artifactId + } else { + entity.ModelArtifact.Id = &artifactId + } + existing, err := s.coreApi.GetArtifactById(artifactId) + if err != nil { + return ErrorResponse(api.ErrToStatus(err), err), err + } + update, err := s.reconciler.UpdateExistingArtifact(converter.NewOpenapiUpdateWrapper(existing, entity)) + if err != nil { + return ErrorResponse(http.StatusBadRequest, err), err + } + result, err := s.coreApi.UpsertArtifact(&update) + if err != nil { + return ErrorResponse(api.ErrToStatus(err), err), err + } + return Response(http.StatusOK, result), nil + // TODO return Response(http.StatusUnauthorized, Error{}), nil +} + // UpdateModelArtifact - Update a ModelArtifact func (s *ModelRegistryServiceAPIService) UpdateModelArtifact(ctx context.Context, modelartifactId string, modelArtifactUpdate model.ModelArtifactUpdate) (ImplResponse, error) { modelArtifact, err := s.converter.ConvertModelArtifactUpdate(&modelArtifactUpdate) diff --git a/internal/server/openapi/type_asserts.go b/internal/server/openapi/type_asserts.go index fa7cde46..c453bd40 100644 --- a/internal/server/openapi/type_asserts.go +++ b/internal/server/openapi/type_asserts.go @@ -21,6 +21,25 @@ func AssertArtifactConstraints(obj model.Artifact) error { return nil } +// AssertArtifactCreateConstraints checks if the values respects the defined constraints +func AssertArtifactCreateConstraints(obj model.ArtifactCreate) error { + return nil +} + +// AssertArtifactCreateRequired checks if the required fields are not zero-ed +func AssertArtifactCreateRequired(obj model.ArtifactCreate) error { + // elements := map[string]interface{}{ + // "artifactType": obj.ArtifactType, + // } + // for name, el := range elements { + // if isZero := IsZeroValue(el); isZero { + // return &RequiredError{Field: name} + // } + // } + + return nil +} + // AssertArtifactListConstraints checks if the values respects the defined constraints func AssertArtifactListConstraints(obj model.ArtifactList) error { return nil @@ -49,6 +68,15 @@ func AssertArtifactListRequired(obj model.ArtifactList) error { // AssertArtifactRequired checks if the required fields are not zero-ed func AssertArtifactRequired(obj model.Artifact) error { + // elements := map[string]interface{}{ + // "artifactType": obj.ArtifactType, + // } + // for name, el := range elements { + // if isZero := IsZeroValue(el); isZero { + // return &RequiredError{Field: name} + // } + // } + return nil } @@ -62,6 +90,25 @@ func AssertArtifactStateRequired(obj model.ArtifactState) error { return nil } +// AssertArtifactUpdateConstraints checks if the values respects the defined constraints +func AssertArtifactUpdateConstraints(obj model.ArtifactUpdate) error { + return nil +} + +// AssertArtifactUpdateRequired checks if the required fields are not zero-ed +func AssertArtifactUpdateRequired(obj model.ArtifactUpdate) error { + // elements := map[string]interface{}{ + // "artifactType": obj.ArtifactType, + // } + // for name, el := range elements { + // if isZero := IsZeroValue(el); isZero { + // return &RequiredError{Field: name} + // } + // } + + return nil +} + // AssertBaseArtifactConstraints checks if the values respects the defined constraints func AssertBaseArtifactConstraints(obj model.BaseArtifact) error { return nil @@ -178,6 +225,25 @@ func AssertDocArtifactConstraints(obj model.DocArtifact) error { return nil } +// AssertDocArtifactCreateConstraints checks if the values respects the defined constraints +func AssertDocArtifactCreateConstraints(obj model.DocArtifactCreate) error { + return nil +} + +// AssertDocArtifactCreateRequired checks if the required fields are not zero-ed +func AssertDocArtifactCreateRequired(obj model.DocArtifactCreate) error { + elements := map[string]interface{}{ + "artifactType": obj.ArtifactType, + } + for name, el := range elements { + if isZero := IsZeroValue(el); isZero { + return &RequiredError{Field: name} + } + } + + return nil +} + // AssertDocArtifactRequired checks if the required fields are not zero-ed func AssertDocArtifactRequired(obj model.DocArtifact) error { elements := map[string]interface{}{ @@ -192,6 +258,25 @@ func AssertDocArtifactRequired(obj model.DocArtifact) error { return nil } +// AssertDocArtifactUpdateConstraints checks if the values respects the defined constraints +func AssertDocArtifactUpdateConstraints(obj model.DocArtifactUpdate) error { + return nil +} + +// AssertDocArtifactUpdateRequired checks if the required fields are not zero-ed +func AssertDocArtifactUpdateRequired(obj model.DocArtifactUpdate) error { + elements := map[string]interface{}{ + "artifactType": obj.ArtifactType, + } + for name, el := range elements { + if isZero := IsZeroValue(el); isZero { + return &RequiredError{Field: name} + } + } + + return nil +} + // AssertErrorConstraints checks if the values respects the defined constraints func AssertErrorConstraints(obj model.Error) error { return nil @@ -468,6 +553,15 @@ func AssertModelArtifactCreateConstraints(obj model.ModelArtifactCreate) error { // AssertModelArtifactCreateRequired checks if the required fields are not zero-ed func AssertModelArtifactCreateRequired(obj model.ModelArtifactCreate) error { + elements := map[string]interface{}{ + "artifactType": obj.ArtifactType, + } + for name, el := range elements { + if isZero := IsZeroValue(el); isZero { + return &RequiredError{Field: name} + } + } + return nil } @@ -518,6 +612,15 @@ func AssertModelArtifactUpdateConstraints(obj model.ModelArtifactUpdate) error { // AssertModelArtifactUpdateRequired checks if the required fields are not zero-ed func AssertModelArtifactUpdateRequired(obj model.ModelArtifactUpdate) error { + elements := map[string]interface{}{ + "artifactType": obj.ArtifactType, + } + for name, el := range elements { + if isZero := IsZeroValue(el); isZero { + return &RequiredError{Field: name} + } + } + return nil } diff --git a/patches/type_asserts.patch b/patches/type_asserts.patch index 485878a1..037aaa67 100644 --- a/patches/type_asserts.patch +++ b/patches/type_asserts.patch @@ -2,6 +2,75 @@ diff --git a/internal/server/openapi/type_asserts.go b/internal/server/openapi/t index b001018..9907fbc 100644 --- a/internal/server/openapi/type_asserts.go +++ b/internal/server/openapi/type_asserts.go +@@ -28,14 +28,14 @@ func AssertArtifactCreateConstraints(obj model.ArtifactCreate) error { + + // AssertArtifactCreateRequired checks if the required fields are not zero-ed + func AssertArtifactCreateRequired(obj model.ArtifactCreate) error { +- elements := map[string]interface{}{ +- "artifactType": obj.ArtifactType, +- } +- for name, el := range elements { +- if isZero := IsZeroValue(el); isZero { +- return &RequiredError{Field: name} +- } +- } ++ // elements := map[string]interface{}{ ++ // "artifactType": obj.ArtifactType, ++ // } ++ // for name, el := range elements { ++ // if isZero := IsZeroValue(el); isZero { ++ // return &RequiredError{Field: name} ++ // } ++ // } + + return nil + } +@@ -68,14 +68,14 @@ func AssertArtifactListRequired(obj model.ArtifactList) error { + + // AssertArtifactRequired checks if the required fields are not zero-ed + func AssertArtifactRequired(obj model.Artifact) error { +- elements := map[string]interface{}{ +- "artifactType": obj.ArtifactType, +- } +- for name, el := range elements { +- if isZero := IsZeroValue(el); isZero { +- return &RequiredError{Field: name} +- } +- } ++ // elements := map[string]interface{}{ ++ // "artifactType": obj.ArtifactType, ++ // } ++ // for name, el := range elements { ++ // if isZero := IsZeroValue(el); isZero { ++ // return &RequiredError{Field: name} ++ // } ++ // } + + return nil + } +@@ -97,14 +97,14 @@ func AssertArtifactUpdateConstraints(obj model.ArtifactUpdate) error { + + // AssertArtifactUpdateRequired checks if the required fields are not zero-ed + func AssertArtifactUpdateRequired(obj model.ArtifactUpdate) error { +- elements := map[string]interface{}{ +- "artifactType": obj.ArtifactType, +- } +- for name, el := range elements { +- if isZero := IsZeroValue(el); isZero { +- return &RequiredError{Field: name} +- } +- } ++ // elements := map[string]interface{}{ ++ // "artifactType": obj.ArtifactType, ++ // } ++ // for name, el := range elements { ++ // if isZero := IsZeroValue(el); isZero { ++ // return &RequiredError{Field: name} ++ // } ++ // } + + return nil + } @@ -449,21 +449,22 @@ func AssertMetadataStructValueConstraints(obj model.MetadataStructValue) error { // AssertMetadataValueRequired checks if the required fields are not zero-ed diff --git a/pkg/api/api.go b/pkg/api/api.go index 96662da6..a3dd3325 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -58,6 +58,8 @@ type ModelRegistryApi interface { GetArtifactById(id string) (*openapi.Artifact, error) + GetArtifactByParams(artifactName *string, modelVersionId *string, externalId *string) (*openapi.Artifact, error) + GetArtifacts(listOptions ListOptions, modelVersionId *string) (*openapi.ArtifactList, error) // MODEL ARTIFACT diff --git a/pkg/core/artifact.go b/pkg/core/artifact.go index 3c06a25b..ad5ccc07 100644 --- a/pkg/core/artifact.go +++ b/pkg/core/artifact.go @@ -18,6 +18,9 @@ import ( // ID is provided. // Upon creation, new artifacts will be associated with their corresponding model version. func (serv *ModelRegistryService) UpsertModelVersionArtifact(artifact *openapi.Artifact, modelVersionId string) (*openapi.Artifact, error) { + if artifact == nil { + return nil, fmt.Errorf("invalid artifact pointer, can't upsert nil: %w", api.ErrBadRequest) + } art, err := serv.upsertArtifact(artifact, &modelVersionId) if err != nil { return nil, err @@ -153,6 +156,48 @@ func (serv *ModelRegistryService) GetArtifactById(id string) (*openapi.Artifact, return serv.mapper.MapToArtifact(artifactsResp.Artifacts[0]) } +// GetArtifactByParams retrieves an artifact based on specified parameters, such as (artifact name and model version ID), or external ID. +// If multiple or no model artifacts are found, an error is returned. +func (serv *ModelRegistryService) GetArtifactByParams(artifactName *string, modelVersionId *string, externalId *string) (*openapi.Artifact, error) { + var artifact0 *proto.Artifact + + filterQuery := "" + if externalId != nil { + filterQuery = fmt.Sprintf("external_id = \"%s\"", *externalId) + } else if artifactName != nil && modelVersionId != nil { + filterQuery = fmt.Sprintf("name = \"%s\"", converter.PrefixWhenOwned(modelVersionId, *artifactName)) + } else { + return nil, fmt.Errorf("invalid parameters call, supply either (artifactName and modelVersionId), or externalId: %w", api.ErrBadRequest) + } + glog.Info("filterQuery ", filterQuery) + + artifactsResponse, err := serv.mlmdClient.GetArtifacts(context.Background(), &proto.GetArtifactsRequest{ + Options: &proto.ListOperationOptions{ + FilterQuery: &filterQuery, + }, + }) + if err != nil { + return nil, err + } + + if len(artifactsResponse.Artifacts) > 1 { + return nil, fmt.Errorf("multiple model artifacts found for artifactName=%v, modelVersionId=%v, externalId=%v: %w", apiutils.ZeroIfNil(artifactName), apiutils.ZeroIfNil(modelVersionId), apiutils.ZeroIfNil(externalId), api.ErrNotFound) + } + + if len(artifactsResponse.Artifacts) == 0 { + return nil, fmt.Errorf("no model artifacts found for artifactName=%v, modelVersionId=%v, externalId=%v: %w", apiutils.ZeroIfNil(artifactName), apiutils.ZeroIfNil(modelVersionId), apiutils.ZeroIfNil(externalId), api.ErrNotFound) + } + + artifact0 = artifactsResponse.Artifacts[0] + + result, err := serv.mapper.MapToArtifact(artifact0) + if err != nil { + return nil, fmt.Errorf("%v: %w", err, api.ErrBadRequest) + } + + return result, nil +} + // GetArtifacts retrieves a list of artifacts based on the provided list options and optional model version ID. func (serv *ModelRegistryService) GetArtifacts(listOptions api.ListOptions, modelVersionId *string) (*openapi.ArtifactList, error) { listOperationOptions, err := apiutils.BuildListOperationOptions(listOptions) diff --git a/pkg/core/artifact_test.go b/pkg/core/artifact_test.go index 12b7f90d..df78ec0c 100644 --- a/pkg/core/artifact_test.go +++ b/pkg/core/artifact_test.go @@ -412,6 +412,59 @@ func (suite *CoreTestSuite) TestGetArtifactById() { suite.Equal(*createdArtifact, *getById, "artifacts returned during creation and on get by id should be equal") } +func (suite *CoreTestSuite) TestGetArtifactByParams() { + // create mode registry service + service := suite.setupModelRegistryService() + + modelVersionId := suite.registerModelVersion(service, nil, nil, nil, nil) + + docArtifact := &openapi.DocArtifact{ + Name: &artifactName, + State: (*openapi.ArtifactState)(&artifactState), + Uri: &artifactUri, + ExternalId: &artifactExtId, + CustomProperties: &map[string]openapi.MetadataValue{ + "custom_string_prop": { + MetadataStringValue: converter.NewMetadataStringValue(customString), + }, + }, + } + + art, err := service.UpsertModelVersionArtifact(&openapi.Artifact{DocArtifact: docArtifact}, modelVersionId) + suite.Nilf(err, "error creating new model artifact: %v", err) + da := art.DocArtifact + + createdArtifactId, _ := converter.StringToInt64(da.Id) + + state, _ := openapi.NewArtifactStateFromValue(artifactState) + + artByName, err := service.GetArtifactByParams(&artifactName, &modelVersionId, nil) + suite.Nilf(err, "error getting model artifact by id %s: %v", *createdArtifactId, err) + daByName := artByName.DocArtifact + + suite.NotNil(da.Id, "created artifact id should not be nil") + suite.Equal(artifactName, *daByName.Name) + suite.Equal(artifactExtId, *daByName.ExternalId) + suite.Equal(*state, *daByName.State) + suite.Equal(artifactUri, *daByName.Uri) + suite.Equal(customString, (*daByName.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue) + + suite.Equal(*da, *daByName, "artifacts returned during creation and on get by name should be equal") + + getByExtId, err := service.GetArtifactByParams(nil, nil, &artifactExtId) + suite.Nilf(err, "error getting model artifact by id %s: %v", *createdArtifactId, err) + daByExtId := getByExtId.DocArtifact + + suite.NotNil(da.Id, "created artifact id should not be nil") + suite.Equal(artifactName, *daByExtId.Name) + suite.Equal(artifactExtId, *daByExtId.ExternalId) + suite.Equal(*state, *daByExtId.State) + suite.Equal(artifactUri, *daByExtId.Uri) + suite.Equal(customString, (*daByExtId.CustomProperties)["custom_string_prop"].MetadataStringValue.StringValue) + + suite.Equal(*da, *daByExtId, "artifacts returned during creation and on get by ext id should be equal") +} + func (suite *CoreTestSuite) TestGetArtifacts() { // create mode registry service service := suite.setupModelRegistryService() diff --git a/pkg/openapi/.openapi-generator/FILES b/pkg/openapi/.openapi-generator/FILES index ba72484a..8a56f21b 100644 --- a/pkg/openapi/.openapi-generator/FILES +++ b/pkg/openapi/.openapi-generator/FILES @@ -2,8 +2,10 @@ api_model_registry_service.go client.go configuration.go model_artifact.go +model_artifact_create.go model_artifact_list.go model_artifact_state.go +model_artifact_update.go model_base_artifact.go model_base_artifact_create.go model_base_artifact_update.go @@ -15,6 +17,8 @@ model_base_resource_create.go model_base_resource_list.go model_base_resource_update.go model_doc_artifact.go +model_doc_artifact_create.go +model_doc_artifact_update.go model_error.go model_execution_state.go model_inference_service.go diff --git a/pkg/openapi/api_model_registry_service.go b/pkg/openapi/api_model_registry_service.go index 646fb530..4904ad21 100644 --- a/pkg/openapi/api_model_registry_service.go +++ b/pkg/openapi/api_model_registry_service.go @@ -22,6 +22,150 @@ import ( // ModelRegistryServiceAPIService ModelRegistryServiceAPI service type ModelRegistryServiceAPIService service +type ApiCreateArtifactRequest struct { + ctx context.Context + ApiService *ModelRegistryServiceAPIService + artifactCreate *ArtifactCreate +} + +// A new `Artifact` to be created. +func (r ApiCreateArtifactRequest) ArtifactCreate(artifactCreate ArtifactCreate) ApiCreateArtifactRequest { + r.artifactCreate = &artifactCreate + return r +} + +func (r ApiCreateArtifactRequest) Execute() (*Artifact, *http.Response, error) { + return r.ApiService.CreateArtifactExecute(r) +} + +/* +CreateArtifact Create an Artifact + +Creates a new instance of an `Artifact`. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiCreateArtifactRequest +*/ +func (a *ModelRegistryServiceAPIService) CreateArtifact(ctx context.Context) ApiCreateArtifactRequest { + return ApiCreateArtifactRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +// +// @return Artifact +func (a *ModelRegistryServiceAPIService) CreateArtifactExecute(r ApiCreateArtifactRequest) (*Artifact, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Artifact + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ModelRegistryServiceAPIService.CreateArtifact") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/model_registry/v1alpha3/artifacts" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.artifactCreate == nil { + return localVarReturnValue, nil, reportError("artifactCreate is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.artifactCreate + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + type ApiCreateEnvironmentInferenceServiceRequest struct { ctx context.Context ApiService *ModelRegistryServiceAPIService @@ -1219,7 +1363,7 @@ func (a *ModelRegistryServiceAPIService) CreateServingEnvironmentExecute(r ApiCr return localVarReturnValue, localVarHTTPResponse, nil } -type ApiFindInferenceServiceRequest struct { +type ApiFindArtifactRequest struct { ctx context.Context ApiService *ModelRegistryServiceAPIService name *string @@ -1228,37 +1372,37 @@ type ApiFindInferenceServiceRequest struct { } // Name of entity to search. -func (r ApiFindInferenceServiceRequest) Name(name string) ApiFindInferenceServiceRequest { +func (r ApiFindArtifactRequest) Name(name string) ApiFindArtifactRequest { r.name = &name return r } // External ID of entity to search. -func (r ApiFindInferenceServiceRequest) ExternalId(externalId string) ApiFindInferenceServiceRequest { +func (r ApiFindArtifactRequest) ExternalId(externalId string) ApiFindArtifactRequest { r.externalId = &externalId return r } // ID of the parent resource to use for search. -func (r ApiFindInferenceServiceRequest) ParentResourceId(parentResourceId string) ApiFindInferenceServiceRequest { +func (r ApiFindArtifactRequest) ParentResourceId(parentResourceId string) ApiFindArtifactRequest { r.parentResourceId = &parentResourceId return r } -func (r ApiFindInferenceServiceRequest) Execute() (*InferenceService, *http.Response, error) { - return r.ApiService.FindInferenceServiceExecute(r) +func (r ApiFindArtifactRequest) Execute() (*Artifact, *http.Response, error) { + return r.ApiService.FindArtifactExecute(r) } /* -FindInferenceService Get an InferenceServices that matches search parameters. +FindArtifact Get an Artifact that matches search parameters. -Gets the details of a single instance of `InferenceService` that matches search parameters. +Gets the details of a single instance of an `Artifact` that matches search parameters. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiFindInferenceServiceRequest + @return ApiFindArtifactRequest */ -func (a *ModelRegistryServiceAPIService) FindInferenceService(ctx context.Context) ApiFindInferenceServiceRequest { - return ApiFindInferenceServiceRequest{ +func (a *ModelRegistryServiceAPIService) FindArtifact(ctx context.Context) ApiFindArtifactRequest { + return ApiFindArtifactRequest{ ApiService: a, ctx: ctx, } @@ -1266,21 +1410,21 @@ func (a *ModelRegistryServiceAPIService) FindInferenceService(ctx context.Contex // Execute executes the request // -// @return InferenceService -func (a *ModelRegistryServiceAPIService) FindInferenceServiceExecute(r ApiFindInferenceServiceRequest) (*InferenceService, *http.Response, error) { +// @return Artifact +func (a *ModelRegistryServiceAPIService) FindArtifactExecute(r ApiFindArtifactRequest) (*Artifact, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile - localVarReturnValue *InferenceService + localVarReturnValue *Artifact ) - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ModelRegistryServiceAPIService.FindInferenceService") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ModelRegistryServiceAPIService.FindArtifact") if err != nil { return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha3/inference_service" + localVarPath := localBasePath + "/api/model_registry/v1alpha3/artifact" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -1392,7 +1536,7 @@ func (a *ModelRegistryServiceAPIService) FindInferenceServiceExecute(r ApiFindIn return localVarReturnValue, localVarHTTPResponse, nil } -type ApiFindModelArtifactRequest struct { +type ApiFindInferenceServiceRequest struct { ctx context.Context ApiService *ModelRegistryServiceAPIService name *string @@ -1401,37 +1545,37 @@ type ApiFindModelArtifactRequest struct { } // Name of entity to search. -func (r ApiFindModelArtifactRequest) Name(name string) ApiFindModelArtifactRequest { +func (r ApiFindInferenceServiceRequest) Name(name string) ApiFindInferenceServiceRequest { r.name = &name return r } // External ID of entity to search. -func (r ApiFindModelArtifactRequest) ExternalId(externalId string) ApiFindModelArtifactRequest { +func (r ApiFindInferenceServiceRequest) ExternalId(externalId string) ApiFindInferenceServiceRequest { r.externalId = &externalId return r } // ID of the parent resource to use for search. -func (r ApiFindModelArtifactRequest) ParentResourceId(parentResourceId string) ApiFindModelArtifactRequest { +func (r ApiFindInferenceServiceRequest) ParentResourceId(parentResourceId string) ApiFindInferenceServiceRequest { r.parentResourceId = &parentResourceId return r } -func (r ApiFindModelArtifactRequest) Execute() (*ModelArtifact, *http.Response, error) { - return r.ApiService.FindModelArtifactExecute(r) +func (r ApiFindInferenceServiceRequest) Execute() (*InferenceService, *http.Response, error) { + return r.ApiService.FindInferenceServiceExecute(r) } /* -FindModelArtifact Get a ModelArtifact that matches search parameters. +FindInferenceService Get an InferenceServices that matches search parameters. -Gets the details of a single instance of a `ModelArtifact` that matches search parameters. +Gets the details of a single instance of `InferenceService` that matches search parameters. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiFindModelArtifactRequest + @return ApiFindInferenceServiceRequest */ -func (a *ModelRegistryServiceAPIService) FindModelArtifact(ctx context.Context) ApiFindModelArtifactRequest { - return ApiFindModelArtifactRequest{ +func (a *ModelRegistryServiceAPIService) FindInferenceService(ctx context.Context) ApiFindInferenceServiceRequest { + return ApiFindInferenceServiceRequest{ ApiService: a, ctx: ctx, } @@ -1439,21 +1583,21 @@ func (a *ModelRegistryServiceAPIService) FindModelArtifact(ctx context.Context) // Execute executes the request // -// @return ModelArtifact -func (a *ModelRegistryServiceAPIService) FindModelArtifactExecute(r ApiFindModelArtifactRequest) (*ModelArtifact, *http.Response, error) { +// @return InferenceService +func (a *ModelRegistryServiceAPIService) FindInferenceServiceExecute(r ApiFindInferenceServiceRequest) (*InferenceService, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile - localVarReturnValue *ModelArtifact + localVarReturnValue *InferenceService ) - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ModelRegistryServiceAPIService.FindModelArtifact") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ModelRegistryServiceAPIService.FindInferenceService") if err != nil { return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha3/model_artifact" + localVarPath := localBasePath + "/api/model_registry/v1alpha3/inference_service" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -1565,7 +1709,7 @@ func (a *ModelRegistryServiceAPIService) FindModelArtifactExecute(r ApiFindModel return localVarReturnValue, localVarHTTPResponse, nil } -type ApiFindModelVersionRequest struct { +type ApiFindModelArtifactRequest struct { ctx context.Context ApiService *ModelRegistryServiceAPIService name *string @@ -1574,37 +1718,37 @@ type ApiFindModelVersionRequest struct { } // Name of entity to search. -func (r ApiFindModelVersionRequest) Name(name string) ApiFindModelVersionRequest { +func (r ApiFindModelArtifactRequest) Name(name string) ApiFindModelArtifactRequest { r.name = &name return r } // External ID of entity to search. -func (r ApiFindModelVersionRequest) ExternalId(externalId string) ApiFindModelVersionRequest { +func (r ApiFindModelArtifactRequest) ExternalId(externalId string) ApiFindModelArtifactRequest { r.externalId = &externalId return r } // ID of the parent resource to use for search. -func (r ApiFindModelVersionRequest) ParentResourceId(parentResourceId string) ApiFindModelVersionRequest { +func (r ApiFindModelArtifactRequest) ParentResourceId(parentResourceId string) ApiFindModelArtifactRequest { r.parentResourceId = &parentResourceId return r } -func (r ApiFindModelVersionRequest) Execute() (*ModelVersion, *http.Response, error) { - return r.ApiService.FindModelVersionExecute(r) +func (r ApiFindModelArtifactRequest) Execute() (*ModelArtifact, *http.Response, error) { + return r.ApiService.FindModelArtifactExecute(r) } /* -FindModelVersion Get a ModelVersion that matches search parameters. +FindModelArtifact Get a ModelArtifact that matches search parameters. -Gets the details of a single instance of a `ModelVersion` that matches search parameters. +Gets the details of a single instance of a `ModelArtifact` that matches search parameters. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiFindModelVersionRequest + @return ApiFindModelArtifactRequest */ -func (a *ModelRegistryServiceAPIService) FindModelVersion(ctx context.Context) ApiFindModelVersionRequest { - return ApiFindModelVersionRequest{ +func (a *ModelRegistryServiceAPIService) FindModelArtifact(ctx context.Context) ApiFindModelArtifactRequest { + return ApiFindModelArtifactRequest{ ApiService: a, ctx: ctx, } @@ -1612,21 +1756,512 @@ func (a *ModelRegistryServiceAPIService) FindModelVersion(ctx context.Context) A // Execute executes the request // -// @return ModelVersion -func (a *ModelRegistryServiceAPIService) FindModelVersionExecute(r ApiFindModelVersionRequest) (*ModelVersion, *http.Response, error) { +// @return ModelArtifact +func (a *ModelRegistryServiceAPIService) FindModelArtifactExecute(r ApiFindModelArtifactRequest) (*ModelArtifact, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile - localVarReturnValue *ModelVersion + localVarReturnValue *ModelArtifact ) - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ModelRegistryServiceAPIService.FindModelVersion") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ModelRegistryServiceAPIService.FindModelArtifact") if err != nil { return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha3/model_version" + localVarPath := localBasePath + "/api/model_registry/v1alpha3/model_artifact" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if r.name != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "name", r.name, "") + } + if r.externalId != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "externalId", r.externalId, "") + } + if r.parentResourceId != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "parentResourceId", r.parentResourceId, "") + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiFindModelVersionRequest struct { + ctx context.Context + ApiService *ModelRegistryServiceAPIService + name *string + externalId *string + parentResourceId *string +} + +// Name of entity to search. +func (r ApiFindModelVersionRequest) Name(name string) ApiFindModelVersionRequest { + r.name = &name + return r +} + +// External ID of entity to search. +func (r ApiFindModelVersionRequest) ExternalId(externalId string) ApiFindModelVersionRequest { + r.externalId = &externalId + return r +} + +// ID of the parent resource to use for search. +func (r ApiFindModelVersionRequest) ParentResourceId(parentResourceId string) ApiFindModelVersionRequest { + r.parentResourceId = &parentResourceId + return r +} + +func (r ApiFindModelVersionRequest) Execute() (*ModelVersion, *http.Response, error) { + return r.ApiService.FindModelVersionExecute(r) +} + +/* +FindModelVersion Get a ModelVersion that matches search parameters. + +Gets the details of a single instance of a `ModelVersion` that matches search parameters. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiFindModelVersionRequest +*/ +func (a *ModelRegistryServiceAPIService) FindModelVersion(ctx context.Context) ApiFindModelVersionRequest { + return ApiFindModelVersionRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +// +// @return ModelVersion +func (a *ModelRegistryServiceAPIService) FindModelVersionExecute(r ApiFindModelVersionRequest) (*ModelVersion, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ModelVersion + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ModelRegistryServiceAPIService.FindModelVersion") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/model_registry/v1alpha3/model_version" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if r.name != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "name", r.name, "") + } + if r.externalId != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "externalId", r.externalId, "") + } + if r.parentResourceId != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "parentResourceId", r.parentResourceId, "") + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiFindRegisteredModelRequest struct { + ctx context.Context + ApiService *ModelRegistryServiceAPIService + name *string + externalId *string +} + +// Name of entity to search. +func (r ApiFindRegisteredModelRequest) Name(name string) ApiFindRegisteredModelRequest { + r.name = &name + return r +} + +// External ID of entity to search. +func (r ApiFindRegisteredModelRequest) ExternalId(externalId string) ApiFindRegisteredModelRequest { + r.externalId = &externalId + return r +} + +func (r ApiFindRegisteredModelRequest) Execute() (*RegisteredModel, *http.Response, error) { + return r.ApiService.FindRegisteredModelExecute(r) +} + +/* +FindRegisteredModel Get a RegisteredModel that matches search parameters. + +Gets the details of a single instance of a `RegisteredModel` that matches search parameters. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiFindRegisteredModelRequest +*/ +func (a *ModelRegistryServiceAPIService) FindRegisteredModel(ctx context.Context) ApiFindRegisteredModelRequest { + return ApiFindRegisteredModelRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +// +// @return RegisteredModel +func (a *ModelRegistryServiceAPIService) FindRegisteredModelExecute(r ApiFindRegisteredModelRequest) (*RegisteredModel, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *RegisteredModel + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ModelRegistryServiceAPIService.FindRegisteredModel") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/model_registry/v1alpha3/registered_model" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if r.name != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "name", r.name, "") + } + if r.externalId != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "externalId", r.externalId, "") + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiFindServingEnvironmentRequest struct { + ctx context.Context + ApiService *ModelRegistryServiceAPIService + name *string + externalId *string +} + +// Name of entity to search. +func (r ApiFindServingEnvironmentRequest) Name(name string) ApiFindServingEnvironmentRequest { + r.name = &name + return r +} + +// External ID of entity to search. +func (r ApiFindServingEnvironmentRequest) ExternalId(externalId string) ApiFindServingEnvironmentRequest { + r.externalId = &externalId + return r +} + +func (r ApiFindServingEnvironmentRequest) Execute() (*ServingEnvironment, *http.Response, error) { + return r.ApiService.FindServingEnvironmentExecute(r) +} + +/* +FindServingEnvironment Find ServingEnvironment + +Finds a `ServingEnvironment` entity that matches query parameters. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiFindServingEnvironmentRequest +*/ +func (a *ModelRegistryServiceAPIService) FindServingEnvironment(ctx context.Context) ApiFindServingEnvironmentRequest { + return ApiFindServingEnvironmentRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +// +// @return ServingEnvironment +func (a *ModelRegistryServiceAPIService) FindServingEnvironmentExecute(r ApiFindServingEnvironmentRequest) (*ServingEnvironment, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ServingEnvironment + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ModelRegistryServiceAPIService.FindServingEnvironment") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/model_registry/v1alpha3/serving_environment" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -1638,9 +2273,6 @@ func (a *ModelRegistryServiceAPIService) FindModelVersionExecute(r ApiFindModelV if r.externalId != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "externalId", r.externalId, "") } - if r.parentResourceId != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "parentResourceId", r.parentResourceId, "") - } // to determine the Content-Type header localVarHTTPContentTypes := []string{} @@ -1680,17 +2312,6 @@ func (a *ModelRegistryServiceAPIService) FindModelVersionExecute(r ApiFindModelV body: localVarBody, error: localVarHTTPResponse.Status, } - if localVarHTTPResponse.StatusCode == 400 { - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } if localVarHTTPResponse.StatusCode == 401 { var v Error err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) @@ -1738,72 +2359,56 @@ func (a *ModelRegistryServiceAPIService) FindModelVersionExecute(r ApiFindModelV return localVarReturnValue, localVarHTTPResponse, nil } -type ApiFindRegisteredModelRequest struct { +type ApiGetArtifactRequest struct { ctx context.Context ApiService *ModelRegistryServiceAPIService - name *string - externalId *string -} - -// Name of entity to search. -func (r ApiFindRegisteredModelRequest) Name(name string) ApiFindRegisteredModelRequest { - r.name = &name - return r -} - -// External ID of entity to search. -func (r ApiFindRegisteredModelRequest) ExternalId(externalId string) ApiFindRegisteredModelRequest { - r.externalId = &externalId - return r + id string } -func (r ApiFindRegisteredModelRequest) Execute() (*RegisteredModel, *http.Response, error) { - return r.ApiService.FindRegisteredModelExecute(r) +func (r ApiGetArtifactRequest) Execute() (*Artifact, *http.Response, error) { + return r.ApiService.GetArtifactExecute(r) } /* -FindRegisteredModel Get a RegisteredModel that matches search parameters. +GetArtifact Get an Artifact -Gets the details of a single instance of a `RegisteredModel` that matches search parameters. +Gets the details of a single instance of an `Artifact`. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiFindRegisteredModelRequest + @param id A unique identifier for an `Artifact`. + @return ApiGetArtifactRequest */ -func (a *ModelRegistryServiceAPIService) FindRegisteredModel(ctx context.Context) ApiFindRegisteredModelRequest { - return ApiFindRegisteredModelRequest{ +func (a *ModelRegistryServiceAPIService) GetArtifact(ctx context.Context, id string) ApiGetArtifactRequest { + return ApiGetArtifactRequest{ ApiService: a, ctx: ctx, + id: id, } } // Execute executes the request // -// @return RegisteredModel -func (a *ModelRegistryServiceAPIService) FindRegisteredModelExecute(r ApiFindRegisteredModelRequest) (*RegisteredModel, *http.Response, error) { +// @return Artifact +func (a *ModelRegistryServiceAPIService) GetArtifactExecute(r ApiGetArtifactRequest) (*Artifact, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile - localVarReturnValue *RegisteredModel + localVarReturnValue *Artifact ) - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ModelRegistryServiceAPIService.FindRegisteredModel") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ModelRegistryServiceAPIService.GetArtifact") if err != nil { return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha3/registered_model" + localVarPath := localBasePath + "/api/model_registry/v1alpha3/artifacts/{id}" + localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - if r.name != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "name", r.name, "") - } - if r.externalId != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "externalId", r.externalId, "") - } // to determine the Content-Type header localVarHTTPContentTypes := []string{} @@ -1890,39 +2495,53 @@ func (a *ModelRegistryServiceAPIService) FindRegisteredModelExecute(r ApiFindReg return localVarReturnValue, localVarHTTPResponse, nil } -type ApiFindServingEnvironmentRequest struct { - ctx context.Context - ApiService *ModelRegistryServiceAPIService - name *string - externalId *string +type ApiGetArtifactsRequest struct { + ctx context.Context + ApiService *ModelRegistryServiceAPIService + pageSize *string + orderBy *OrderByField + sortOrder *SortOrder + nextPageToken *string } -// Name of entity to search. -func (r ApiFindServingEnvironmentRequest) Name(name string) ApiFindServingEnvironmentRequest { - r.name = &name +// Number of entities in each page. +func (r ApiGetArtifactsRequest) PageSize(pageSize string) ApiGetArtifactsRequest { + r.pageSize = &pageSize return r } -// External ID of entity to search. -func (r ApiFindServingEnvironmentRequest) ExternalId(externalId string) ApiFindServingEnvironmentRequest { - r.externalId = &externalId +// Specifies the order by criteria for listing entities. +func (r ApiGetArtifactsRequest) OrderBy(orderBy OrderByField) ApiGetArtifactsRequest { + r.orderBy = &orderBy return r } -func (r ApiFindServingEnvironmentRequest) Execute() (*ServingEnvironment, *http.Response, error) { - return r.ApiService.FindServingEnvironmentExecute(r) +// Specifies the sort order for listing entities, defaults to ASC. +func (r ApiGetArtifactsRequest) SortOrder(sortOrder SortOrder) ApiGetArtifactsRequest { + r.sortOrder = &sortOrder + return r +} + +// Token to use to retrieve next page of results. +func (r ApiGetArtifactsRequest) NextPageToken(nextPageToken string) ApiGetArtifactsRequest { + r.nextPageToken = &nextPageToken + return r +} + +func (r ApiGetArtifactsRequest) Execute() (*ArtifactList, *http.Response, error) { + return r.ApiService.GetArtifactsExecute(r) } /* -FindServingEnvironment Find ServingEnvironment +GetArtifacts List All Artifacts -Finds a `ServingEnvironment` entity that matches query parameters. +Gets a list of all `Artifact` entities. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiFindServingEnvironmentRequest + @return ApiGetArtifactsRequest */ -func (a *ModelRegistryServiceAPIService) FindServingEnvironment(ctx context.Context) ApiFindServingEnvironmentRequest { - return ApiFindServingEnvironmentRequest{ +func (a *ModelRegistryServiceAPIService) GetArtifacts(ctx context.Context) ApiGetArtifactsRequest { + return ApiGetArtifactsRequest{ ApiService: a, ctx: ctx, } @@ -1930,31 +2549,37 @@ func (a *ModelRegistryServiceAPIService) FindServingEnvironment(ctx context.Cont // Execute executes the request // -// @return ServingEnvironment -func (a *ModelRegistryServiceAPIService) FindServingEnvironmentExecute(r ApiFindServingEnvironmentRequest) (*ServingEnvironment, *http.Response, error) { +// @return ArtifactList +func (a *ModelRegistryServiceAPIService) GetArtifactsExecute(r ApiGetArtifactsRequest) (*ArtifactList, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile - localVarReturnValue *ServingEnvironment + localVarReturnValue *ArtifactList ) - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ModelRegistryServiceAPIService.FindServingEnvironment") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ModelRegistryServiceAPIService.GetArtifacts") if err != nil { return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/model_registry/v1alpha3/serving_environment" + localVarPath := localBasePath + "/api/model_registry/v1alpha3/artifacts" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - if r.name != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "name", r.name, "") + if r.pageSize != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "pageSize", r.pageSize, "") } - if r.externalId != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "externalId", r.externalId, "") + if r.orderBy != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "orderBy", r.orderBy, "") + } + if r.sortOrder != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "sortOrder", r.sortOrder, "") + } + if r.nextPageToken != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "nextPageToken", r.nextPageToken, "") } // to determine the Content-Type header localVarHTTPContentTypes := []string{} @@ -1995,6 +2620,17 @@ func (a *ModelRegistryServiceAPIService) FindServingEnvironmentExecute(r ApiFind body: localVarBody, error: localVarHTTPResponse.Status, } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } if localVarHTTPResponse.StatusCode == 401 { var v Error err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) @@ -4625,6 +5261,165 @@ func (a *ModelRegistryServiceAPIService) GetServingEnvironmentsExecute(r ApiGetS return localVarReturnValue, localVarHTTPResponse, nil } +type ApiUpdateArtifactRequest struct { + ctx context.Context + ApiService *ModelRegistryServiceAPIService + id string + artifactUpdate *ArtifactUpdate +} + +// Updated `Artifact` information. +func (r ApiUpdateArtifactRequest) ArtifactUpdate(artifactUpdate ArtifactUpdate) ApiUpdateArtifactRequest { + r.artifactUpdate = &artifactUpdate + return r +} + +func (r ApiUpdateArtifactRequest) Execute() (*Artifact, *http.Response, error) { + return r.ApiService.UpdateArtifactExecute(r) +} + +/* +UpdateArtifact Update an Artifact + +Updates an existing `Artifact`. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param id A unique identifier for an `Artifact`. + @return ApiUpdateArtifactRequest +*/ +func (a *ModelRegistryServiceAPIService) UpdateArtifact(ctx context.Context, id string) ApiUpdateArtifactRequest { + return ApiUpdateArtifactRequest{ + ApiService: a, + ctx: ctx, + id: id, + } +} + +// Execute executes the request +// +// @return Artifact +func (a *ModelRegistryServiceAPIService) UpdateArtifactExecute(r ApiUpdateArtifactRequest) (*Artifact, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPatch + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Artifact + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ModelRegistryServiceAPIService.UpdateArtifact") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/model_registry/v1alpha3/artifacts/{id}" + localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.artifactUpdate == nil { + return localVarReturnValue, nil, reportError("artifactUpdate is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.artifactUpdate + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + type ApiUpdateInferenceServiceRequest struct { ctx context.Context ApiService *ModelRegistryServiceAPIService diff --git a/pkg/openapi/model_artifact_create.go b/pkg/openapi/model_artifact_create.go new file mode 100644 index 00000000..88755d3b --- /dev/null +++ b/pkg/openapi/model_artifact_create.go @@ -0,0 +1,163 @@ +/* +Model Registry REST API + +REST API for Model Registry to create and manage ML model metadata + +API version: v1alpha3 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package openapi + +import ( + "encoding/json" + "fmt" +) + +// ArtifactCreate - An Artifact to be created. +type ArtifactCreate struct { + DocArtifactCreate *DocArtifactCreate + ModelArtifactCreate *ModelArtifactCreate +} + +// DocArtifactCreateAsArtifactCreate is a convenience function that returns DocArtifactCreate wrapped in ArtifactCreate +func DocArtifactCreateAsArtifactCreate(v *DocArtifactCreate) ArtifactCreate { + return ArtifactCreate{ + DocArtifactCreate: v, + } +} + +// ModelArtifactCreateAsArtifactCreate is a convenience function that returns ModelArtifactCreate wrapped in ArtifactCreate +func ModelArtifactCreateAsArtifactCreate(v *ModelArtifactCreate) ArtifactCreate { + return ArtifactCreate{ + ModelArtifactCreate: v, + } +} + +// Unmarshal JSON data into one of the pointers in the struct +func (dst *ArtifactCreate) UnmarshalJSON(data []byte) error { + var err error + // use discriminator value to speed up the lookup + var jsonDict map[string]interface{} + err = newStrictDecoder(data).Decode(&jsonDict) + if err != nil { + return fmt.Errorf("failed to unmarshal JSON into map for the discriminator lookup") + } + + // check if the discriminator value is 'DocArtifactCreate' + if jsonDict["artifactType"] == "DocArtifactCreate" { + // try to unmarshal JSON data into DocArtifactCreate + err = json.Unmarshal(data, &dst.DocArtifactCreate) + if err == nil { + return nil // data stored in dst.DocArtifactCreate, return on the first match + } else { + dst.DocArtifactCreate = nil + return fmt.Errorf("failed to unmarshal ArtifactCreate as DocArtifactCreate: %s", err.Error()) + } + } + + // check if the discriminator value is 'ModelArtifactCreate' + if jsonDict["artifactType"] == "ModelArtifactCreate" { + // try to unmarshal JSON data into ModelArtifactCreate + err = json.Unmarshal(data, &dst.ModelArtifactCreate) + if err == nil { + return nil // data stored in dst.ModelArtifactCreate, return on the first match + } else { + dst.ModelArtifactCreate = nil + return fmt.Errorf("failed to unmarshal ArtifactCreate as ModelArtifactCreate: %s", err.Error()) + } + } + + // check if the discriminator value is 'doc-artifact' + if jsonDict["artifactType"] == "doc-artifact" { + // try to unmarshal JSON data into DocArtifactCreate + err = json.Unmarshal(data, &dst.DocArtifactCreate) + if err == nil { + return nil // data stored in dst.DocArtifactCreate, return on the first match + } else { + dst.DocArtifactCreate = nil + return fmt.Errorf("failed to unmarshal ArtifactCreate as DocArtifactCreate: %s", err.Error()) + } + } + + // check if the discriminator value is 'model-artifact' + if jsonDict["artifactType"] == "model-artifact" { + // try to unmarshal JSON data into ModelArtifactCreate + err = json.Unmarshal(data, &dst.ModelArtifactCreate) + if err == nil { + return nil // data stored in dst.ModelArtifactCreate, return on the first match + } else { + dst.ModelArtifactCreate = nil + return fmt.Errorf("failed to unmarshal ArtifactCreate as ModelArtifactCreate: %s", err.Error()) + } + } + + return nil +} + +// Marshal data from the first non-nil pointers in the struct to JSON +func (src ArtifactCreate) MarshalJSON() ([]byte, error) { + if src.DocArtifactCreate != nil { + return json.Marshal(&src.DocArtifactCreate) + } + + if src.ModelArtifactCreate != nil { + return json.Marshal(&src.ModelArtifactCreate) + } + + return nil, nil // no data in oneOf schemas +} + +// Get the actual instance +func (obj *ArtifactCreate) GetActualInstance() interface{} { + if obj == nil { + return nil + } + if obj.DocArtifactCreate != nil { + return obj.DocArtifactCreate + } + + if obj.ModelArtifactCreate != nil { + return obj.ModelArtifactCreate + } + + // all schemas are nil + return nil +} + +type NullableArtifactCreate struct { + value *ArtifactCreate + isSet bool +} + +func (v NullableArtifactCreate) Get() *ArtifactCreate { + return v.value +} + +func (v *NullableArtifactCreate) Set(val *ArtifactCreate) { + v.value = val + v.isSet = true +} + +func (v NullableArtifactCreate) IsSet() bool { + return v.isSet +} + +func (v *NullableArtifactCreate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableArtifactCreate(val *ArtifactCreate) *NullableArtifactCreate { + return &NullableArtifactCreate{value: val, isSet: true} +} + +func (v NullableArtifactCreate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableArtifactCreate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/openapi/model_artifact_update.go b/pkg/openapi/model_artifact_update.go new file mode 100644 index 00000000..2c9b1a03 --- /dev/null +++ b/pkg/openapi/model_artifact_update.go @@ -0,0 +1,163 @@ +/* +Model Registry REST API + +REST API for Model Registry to create and manage ML model metadata + +API version: v1alpha3 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package openapi + +import ( + "encoding/json" + "fmt" +) + +// ArtifactUpdate - An Artifact to be updated. +type ArtifactUpdate struct { + DocArtifactUpdate *DocArtifactUpdate + ModelArtifactUpdate *ModelArtifactUpdate +} + +// DocArtifactUpdateAsArtifactUpdate is a convenience function that returns DocArtifactUpdate wrapped in ArtifactUpdate +func DocArtifactUpdateAsArtifactUpdate(v *DocArtifactUpdate) ArtifactUpdate { + return ArtifactUpdate{ + DocArtifactUpdate: v, + } +} + +// ModelArtifactUpdateAsArtifactUpdate is a convenience function that returns ModelArtifactUpdate wrapped in ArtifactUpdate +func ModelArtifactUpdateAsArtifactUpdate(v *ModelArtifactUpdate) ArtifactUpdate { + return ArtifactUpdate{ + ModelArtifactUpdate: v, + } +} + +// Unmarshal JSON data into one of the pointers in the struct +func (dst *ArtifactUpdate) UnmarshalJSON(data []byte) error { + var err error + // use discriminator value to speed up the lookup + var jsonDict map[string]interface{} + err = newStrictDecoder(data).Decode(&jsonDict) + if err != nil { + return fmt.Errorf("failed to unmarshal JSON into map for the discriminator lookup") + } + + // check if the discriminator value is 'DocArtifactUpdate' + if jsonDict["artifactType"] == "DocArtifactUpdate" { + // try to unmarshal JSON data into DocArtifactUpdate + err = json.Unmarshal(data, &dst.DocArtifactUpdate) + if err == nil { + return nil // data stored in dst.DocArtifactUpdate, return on the first match + } else { + dst.DocArtifactUpdate = nil + return fmt.Errorf("failed to unmarshal ArtifactUpdate as DocArtifactUpdate: %s", err.Error()) + } + } + + // check if the discriminator value is 'ModelArtifactUpdate' + if jsonDict["artifactType"] == "ModelArtifactUpdate" { + // try to unmarshal JSON data into ModelArtifactUpdate + err = json.Unmarshal(data, &dst.ModelArtifactUpdate) + if err == nil { + return nil // data stored in dst.ModelArtifactUpdate, return on the first match + } else { + dst.ModelArtifactUpdate = nil + return fmt.Errorf("failed to unmarshal ArtifactUpdate as ModelArtifactUpdate: %s", err.Error()) + } + } + + // check if the discriminator value is 'doc-artifact' + if jsonDict["artifactType"] == "doc-artifact" { + // try to unmarshal JSON data into DocArtifactUpdate + err = json.Unmarshal(data, &dst.DocArtifactUpdate) + if err == nil { + return nil // data stored in dst.DocArtifactUpdate, return on the first match + } else { + dst.DocArtifactUpdate = nil + return fmt.Errorf("failed to unmarshal ArtifactUpdate as DocArtifactUpdate: %s", err.Error()) + } + } + + // check if the discriminator value is 'model-artifact' + if jsonDict["artifactType"] == "model-artifact" { + // try to unmarshal JSON data into ModelArtifactUpdate + err = json.Unmarshal(data, &dst.ModelArtifactUpdate) + if err == nil { + return nil // data stored in dst.ModelArtifactUpdate, return on the first match + } else { + dst.ModelArtifactUpdate = nil + return fmt.Errorf("failed to unmarshal ArtifactUpdate as ModelArtifactUpdate: %s", err.Error()) + } + } + + return nil +} + +// Marshal data from the first non-nil pointers in the struct to JSON +func (src ArtifactUpdate) MarshalJSON() ([]byte, error) { + if src.DocArtifactUpdate != nil { + return json.Marshal(&src.DocArtifactUpdate) + } + + if src.ModelArtifactUpdate != nil { + return json.Marshal(&src.ModelArtifactUpdate) + } + + return nil, nil // no data in oneOf schemas +} + +// Get the actual instance +func (obj *ArtifactUpdate) GetActualInstance() interface{} { + if obj == nil { + return nil + } + if obj.DocArtifactUpdate != nil { + return obj.DocArtifactUpdate + } + + if obj.ModelArtifactUpdate != nil { + return obj.ModelArtifactUpdate + } + + // all schemas are nil + return nil +} + +type NullableArtifactUpdate struct { + value *ArtifactUpdate + isSet bool +} + +func (v NullableArtifactUpdate) Get() *ArtifactUpdate { + return v.value +} + +func (v *NullableArtifactUpdate) Set(val *ArtifactUpdate) { + v.value = val + v.isSet = true +} + +func (v NullableArtifactUpdate) IsSet() bool { + return v.isSet +} + +func (v *NullableArtifactUpdate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableArtifactUpdate(val *ArtifactUpdate) *NullableArtifactUpdate { + return &NullableArtifactUpdate{value: val, isSet: true} +} + +func (v NullableArtifactUpdate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableArtifactUpdate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/openapi/model_doc_artifact.go b/pkg/openapi/model_doc_artifact.go index 2396dc48..8337fa16 100644 --- a/pkg/openapi/model_doc_artifact.go +++ b/pkg/openapi/model_doc_artifact.go @@ -19,7 +19,6 @@ var _ MappedNullable = &DocArtifact{} // DocArtifact A document. type DocArtifact struct { - ArtifactType string `json:"artifactType"` // User provided custom properties which are not defined by its type. CustomProperties *map[string]MetadataValue `json:"customProperties,omitempty"` // An optional description about the resource. @@ -37,6 +36,7 @@ type DocArtifact struct { CreateTimeSinceEpoch *string `json:"createTimeSinceEpoch,omitempty"` // Output only. Last update time of the resource since epoch in millisecond since epoch. LastUpdateTimeSinceEpoch *string `json:"lastUpdateTimeSinceEpoch,omitempty"` + ArtifactType string `json:"artifactType"` } // NewDocArtifact instantiates a new DocArtifact object @@ -47,6 +47,7 @@ func NewDocArtifact(artifactType string) *DocArtifact { this := DocArtifact{} var state ArtifactState = ARTIFACTSTATE_UNKNOWN this.State = &state + this.ArtifactType = artifactType return &this } @@ -55,37 +56,13 @@ func NewDocArtifact(artifactType string) *DocArtifact { // but it doesn't guarantee that properties required by API are set func NewDocArtifactWithDefaults() *DocArtifact { this := DocArtifact{} - var artifactType string = "doc-artifact" - this.ArtifactType = artifactType var state ArtifactState = ARTIFACTSTATE_UNKNOWN this.State = &state + var artifactType string = "doc-artifact" + this.ArtifactType = artifactType return &this } -// GetArtifactType returns the ArtifactType field value -func (o *DocArtifact) GetArtifactType() string { - if o == nil { - var ret string - return ret - } - - return o.ArtifactType -} - -// GetArtifactTypeOk returns a tuple with the ArtifactType field value -// and a boolean to check if the value has been set. -func (o *DocArtifact) GetArtifactTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ArtifactType, true -} - -// SetArtifactType sets field value -func (o *DocArtifact) SetArtifactType(v string) { - o.ArtifactType = v -} - // GetCustomProperties returns the CustomProperties field value if set, zero value otherwise. func (o *DocArtifact) GetCustomProperties() map[string]MetadataValue { if o == nil || IsNil(o.CustomProperties) { @@ -374,6 +351,30 @@ func (o *DocArtifact) SetLastUpdateTimeSinceEpoch(v string) { o.LastUpdateTimeSinceEpoch = &v } +// GetArtifactType returns the ArtifactType field value +func (o *DocArtifact) GetArtifactType() string { + if o == nil { + var ret string + return ret + } + + return o.ArtifactType +} + +// GetArtifactTypeOk returns a tuple with the ArtifactType field value +// and a boolean to check if the value has been set. +func (o *DocArtifact) GetArtifactTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ArtifactType, true +} + +// SetArtifactType sets field value +func (o *DocArtifact) SetArtifactType(v string) { + o.ArtifactType = v +} + func (o DocArtifact) MarshalJSON() ([]byte, error) { toSerialize, err := o.ToMap() if err != nil { @@ -384,7 +385,6 @@ func (o DocArtifact) MarshalJSON() ([]byte, error) { func (o DocArtifact) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - toSerialize["artifactType"] = o.ArtifactType if !IsNil(o.CustomProperties) { toSerialize["customProperties"] = o.CustomProperties } @@ -412,6 +412,7 @@ func (o DocArtifact) ToMap() (map[string]interface{}, error) { if !IsNil(o.LastUpdateTimeSinceEpoch) { toSerialize["lastUpdateTimeSinceEpoch"] = o.LastUpdateTimeSinceEpoch } + toSerialize["artifactType"] = o.ArtifactType return toSerialize, nil } diff --git a/pkg/openapi/model_doc_artifact_create.go b/pkg/openapi/model_doc_artifact_create.go new file mode 100644 index 00000000..3f719de3 --- /dev/null +++ b/pkg/openapi/model_doc_artifact_create.go @@ -0,0 +1,342 @@ +/* +Model Registry REST API + +REST API for Model Registry to create and manage ML model metadata + +API version: v1alpha3 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package openapi + +import ( + "encoding/json" +) + +// checks if the DocArtifactCreate type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &DocArtifactCreate{} + +// DocArtifactCreate A document artifact to be created. +type DocArtifactCreate struct { + // User provided custom properties which are not defined by its type. + CustomProperties *map[string]MetadataValue `json:"customProperties,omitempty"` + // An optional description about the resource. + Description *string `json:"description,omitempty"` + // The external id that come from the clients’ system. This field is optional. If set, it must be unique among all resources within a database instance. + ExternalId *string `json:"externalId,omitempty"` + // The uniform resource identifier of the physical artifact. May be empty if there is no physical artifact. + Uri *string `json:"uri,omitempty"` + State *ArtifactState `json:"state,omitempty"` + // The client provided name of the artifact. This field is optional. If set, it must be unique among all the artifacts of the same artifact type within a database instance and cannot be changed once set. + Name *string `json:"name,omitempty"` + ArtifactType string `json:"artifactType"` +} + +// NewDocArtifactCreate instantiates a new DocArtifactCreate object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewDocArtifactCreate(artifactType string) *DocArtifactCreate { + this := DocArtifactCreate{} + var state ArtifactState = ARTIFACTSTATE_UNKNOWN + this.State = &state + this.ArtifactType = artifactType + return &this +} + +// NewDocArtifactCreateWithDefaults instantiates a new DocArtifactCreate object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewDocArtifactCreateWithDefaults() *DocArtifactCreate { + this := DocArtifactCreate{} + var state ArtifactState = ARTIFACTSTATE_UNKNOWN + this.State = &state + var artifactType string = "doc-artifact" + this.ArtifactType = artifactType + return &this +} + +// GetCustomProperties returns the CustomProperties field value if set, zero value otherwise. +func (o *DocArtifactCreate) GetCustomProperties() map[string]MetadataValue { + if o == nil || IsNil(o.CustomProperties) { + var ret map[string]MetadataValue + return ret + } + return *o.CustomProperties +} + +// GetCustomPropertiesOk returns a tuple with the CustomProperties field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DocArtifactCreate) GetCustomPropertiesOk() (*map[string]MetadataValue, bool) { + if o == nil || IsNil(o.CustomProperties) { + return nil, false + } + return o.CustomProperties, true +} + +// HasCustomProperties returns a boolean if a field has been set. +func (o *DocArtifactCreate) HasCustomProperties() bool { + if o != nil && !IsNil(o.CustomProperties) { + return true + } + + return false +} + +// SetCustomProperties gets a reference to the given map[string]MetadataValue and assigns it to the CustomProperties field. +func (o *DocArtifactCreate) SetCustomProperties(v map[string]MetadataValue) { + o.CustomProperties = &v +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *DocArtifactCreate) GetDescription() string { + if o == nil || IsNil(o.Description) { + var ret string + return ret + } + return *o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DocArtifactCreate) GetDescriptionOk() (*string, bool) { + if o == nil || IsNil(o.Description) { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *DocArtifactCreate) HasDescription() bool { + if o != nil && !IsNil(o.Description) { + return true + } + + return false +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *DocArtifactCreate) SetDescription(v string) { + o.Description = &v +} + +// GetExternalId returns the ExternalId field value if set, zero value otherwise. +func (o *DocArtifactCreate) GetExternalId() string { + if o == nil || IsNil(o.ExternalId) { + var ret string + return ret + } + return *o.ExternalId +} + +// GetExternalIdOk returns a tuple with the ExternalId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DocArtifactCreate) GetExternalIdOk() (*string, bool) { + if o == nil || IsNil(o.ExternalId) { + return nil, false + } + return o.ExternalId, true +} + +// HasExternalId returns a boolean if a field has been set. +func (o *DocArtifactCreate) HasExternalId() bool { + if o != nil && !IsNil(o.ExternalId) { + return true + } + + return false +} + +// SetExternalId gets a reference to the given string and assigns it to the ExternalId field. +func (o *DocArtifactCreate) SetExternalId(v string) { + o.ExternalId = &v +} + +// GetUri returns the Uri field value if set, zero value otherwise. +func (o *DocArtifactCreate) GetUri() string { + if o == nil || IsNil(o.Uri) { + var ret string + return ret + } + return *o.Uri +} + +// GetUriOk returns a tuple with the Uri field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DocArtifactCreate) GetUriOk() (*string, bool) { + if o == nil || IsNil(o.Uri) { + return nil, false + } + return o.Uri, true +} + +// HasUri returns a boolean if a field has been set. +func (o *DocArtifactCreate) HasUri() bool { + if o != nil && !IsNil(o.Uri) { + return true + } + + return false +} + +// SetUri gets a reference to the given string and assigns it to the Uri field. +func (o *DocArtifactCreate) SetUri(v string) { + o.Uri = &v +} + +// GetState returns the State field value if set, zero value otherwise. +func (o *DocArtifactCreate) GetState() ArtifactState { + if o == nil || IsNil(o.State) { + var ret ArtifactState + return ret + } + return *o.State +} + +// GetStateOk returns a tuple with the State field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DocArtifactCreate) GetStateOk() (*ArtifactState, bool) { + if o == nil || IsNil(o.State) { + return nil, false + } + return o.State, true +} + +// HasState returns a boolean if a field has been set. +func (o *DocArtifactCreate) HasState() bool { + if o != nil && !IsNil(o.State) { + return true + } + + return false +} + +// SetState gets a reference to the given ArtifactState and assigns it to the State field. +func (o *DocArtifactCreate) SetState(v ArtifactState) { + o.State = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *DocArtifactCreate) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DocArtifactCreate) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *DocArtifactCreate) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *DocArtifactCreate) SetName(v string) { + o.Name = &v +} + +// GetArtifactType returns the ArtifactType field value +func (o *DocArtifactCreate) GetArtifactType() string { + if o == nil { + var ret string + return ret + } + + return o.ArtifactType +} + +// GetArtifactTypeOk returns a tuple with the ArtifactType field value +// and a boolean to check if the value has been set. +func (o *DocArtifactCreate) GetArtifactTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ArtifactType, true +} + +// SetArtifactType sets field value +func (o *DocArtifactCreate) SetArtifactType(v string) { + o.ArtifactType = v +} + +func (o DocArtifactCreate) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o DocArtifactCreate) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.CustomProperties) { + toSerialize["customProperties"] = o.CustomProperties + } + if !IsNil(o.Description) { + toSerialize["description"] = o.Description + } + if !IsNil(o.ExternalId) { + toSerialize["externalId"] = o.ExternalId + } + if !IsNil(o.Uri) { + toSerialize["uri"] = o.Uri + } + if !IsNil(o.State) { + toSerialize["state"] = o.State + } + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + toSerialize["artifactType"] = o.ArtifactType + return toSerialize, nil +} + +type NullableDocArtifactCreate struct { + value *DocArtifactCreate + isSet bool +} + +func (v NullableDocArtifactCreate) Get() *DocArtifactCreate { + return v.value +} + +func (v *NullableDocArtifactCreate) Set(val *DocArtifactCreate) { + v.value = val + v.isSet = true +} + +func (v NullableDocArtifactCreate) IsSet() bool { + return v.isSet +} + +func (v *NullableDocArtifactCreate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDocArtifactCreate(val *DocArtifactCreate) *NullableDocArtifactCreate { + return &NullableDocArtifactCreate{value: val, isSet: true} +} + +func (v NullableDocArtifactCreate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDocArtifactCreate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/openapi/model_doc_artifact_update.go b/pkg/openapi/model_doc_artifact_update.go new file mode 100644 index 00000000..e8337b36 --- /dev/null +++ b/pkg/openapi/model_doc_artifact_update.go @@ -0,0 +1,305 @@ +/* +Model Registry REST API + +REST API for Model Registry to create and manage ML model metadata + +API version: v1alpha3 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package openapi + +import ( + "encoding/json" +) + +// checks if the DocArtifactUpdate type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &DocArtifactUpdate{} + +// DocArtifactUpdate A document artifact to be updated. +type DocArtifactUpdate struct { + // User provided custom properties which are not defined by its type. + CustomProperties *map[string]MetadataValue `json:"customProperties,omitempty"` + // An optional description about the resource. + Description *string `json:"description,omitempty"` + // The external id that come from the clients’ system. This field is optional. If set, it must be unique among all resources within a database instance. + ExternalId *string `json:"externalId,omitempty"` + // The uniform resource identifier of the physical artifact. May be empty if there is no physical artifact. + Uri *string `json:"uri,omitempty"` + State *ArtifactState `json:"state,omitempty"` + ArtifactType string `json:"artifactType"` +} + +// NewDocArtifactUpdate instantiates a new DocArtifactUpdate object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewDocArtifactUpdate(artifactType string) *DocArtifactUpdate { + this := DocArtifactUpdate{} + var state ArtifactState = ARTIFACTSTATE_UNKNOWN + this.State = &state + this.ArtifactType = artifactType + return &this +} + +// NewDocArtifactUpdateWithDefaults instantiates a new DocArtifactUpdate object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewDocArtifactUpdateWithDefaults() *DocArtifactUpdate { + this := DocArtifactUpdate{} + var state ArtifactState = ARTIFACTSTATE_UNKNOWN + this.State = &state + var artifactType string = "doc-artifact" + this.ArtifactType = artifactType + return &this +} + +// GetCustomProperties returns the CustomProperties field value if set, zero value otherwise. +func (o *DocArtifactUpdate) GetCustomProperties() map[string]MetadataValue { + if o == nil || IsNil(o.CustomProperties) { + var ret map[string]MetadataValue + return ret + } + return *o.CustomProperties +} + +// GetCustomPropertiesOk returns a tuple with the CustomProperties field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DocArtifactUpdate) GetCustomPropertiesOk() (*map[string]MetadataValue, bool) { + if o == nil || IsNil(o.CustomProperties) { + return nil, false + } + return o.CustomProperties, true +} + +// HasCustomProperties returns a boolean if a field has been set. +func (o *DocArtifactUpdate) HasCustomProperties() bool { + if o != nil && !IsNil(o.CustomProperties) { + return true + } + + return false +} + +// SetCustomProperties gets a reference to the given map[string]MetadataValue and assigns it to the CustomProperties field. +func (o *DocArtifactUpdate) SetCustomProperties(v map[string]MetadataValue) { + o.CustomProperties = &v +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *DocArtifactUpdate) GetDescription() string { + if o == nil || IsNil(o.Description) { + var ret string + return ret + } + return *o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DocArtifactUpdate) GetDescriptionOk() (*string, bool) { + if o == nil || IsNil(o.Description) { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *DocArtifactUpdate) HasDescription() bool { + if o != nil && !IsNil(o.Description) { + return true + } + + return false +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *DocArtifactUpdate) SetDescription(v string) { + o.Description = &v +} + +// GetExternalId returns the ExternalId field value if set, zero value otherwise. +func (o *DocArtifactUpdate) GetExternalId() string { + if o == nil || IsNil(o.ExternalId) { + var ret string + return ret + } + return *o.ExternalId +} + +// GetExternalIdOk returns a tuple with the ExternalId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DocArtifactUpdate) GetExternalIdOk() (*string, bool) { + if o == nil || IsNil(o.ExternalId) { + return nil, false + } + return o.ExternalId, true +} + +// HasExternalId returns a boolean if a field has been set. +func (o *DocArtifactUpdate) HasExternalId() bool { + if o != nil && !IsNil(o.ExternalId) { + return true + } + + return false +} + +// SetExternalId gets a reference to the given string and assigns it to the ExternalId field. +func (o *DocArtifactUpdate) SetExternalId(v string) { + o.ExternalId = &v +} + +// GetUri returns the Uri field value if set, zero value otherwise. +func (o *DocArtifactUpdate) GetUri() string { + if o == nil || IsNil(o.Uri) { + var ret string + return ret + } + return *o.Uri +} + +// GetUriOk returns a tuple with the Uri field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DocArtifactUpdate) GetUriOk() (*string, bool) { + if o == nil || IsNil(o.Uri) { + return nil, false + } + return o.Uri, true +} + +// HasUri returns a boolean if a field has been set. +func (o *DocArtifactUpdate) HasUri() bool { + if o != nil && !IsNil(o.Uri) { + return true + } + + return false +} + +// SetUri gets a reference to the given string and assigns it to the Uri field. +func (o *DocArtifactUpdate) SetUri(v string) { + o.Uri = &v +} + +// GetState returns the State field value if set, zero value otherwise. +func (o *DocArtifactUpdate) GetState() ArtifactState { + if o == nil || IsNil(o.State) { + var ret ArtifactState + return ret + } + return *o.State +} + +// GetStateOk returns a tuple with the State field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DocArtifactUpdate) GetStateOk() (*ArtifactState, bool) { + if o == nil || IsNil(o.State) { + return nil, false + } + return o.State, true +} + +// HasState returns a boolean if a field has been set. +func (o *DocArtifactUpdate) HasState() bool { + if o != nil && !IsNil(o.State) { + return true + } + + return false +} + +// SetState gets a reference to the given ArtifactState and assigns it to the State field. +func (o *DocArtifactUpdate) SetState(v ArtifactState) { + o.State = &v +} + +// GetArtifactType returns the ArtifactType field value +func (o *DocArtifactUpdate) GetArtifactType() string { + if o == nil { + var ret string + return ret + } + + return o.ArtifactType +} + +// GetArtifactTypeOk returns a tuple with the ArtifactType field value +// and a boolean to check if the value has been set. +func (o *DocArtifactUpdate) GetArtifactTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ArtifactType, true +} + +// SetArtifactType sets field value +func (o *DocArtifactUpdate) SetArtifactType(v string) { + o.ArtifactType = v +} + +func (o DocArtifactUpdate) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o DocArtifactUpdate) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.CustomProperties) { + toSerialize["customProperties"] = o.CustomProperties + } + if !IsNil(o.Description) { + toSerialize["description"] = o.Description + } + if !IsNil(o.ExternalId) { + toSerialize["externalId"] = o.ExternalId + } + if !IsNil(o.Uri) { + toSerialize["uri"] = o.Uri + } + if !IsNil(o.State) { + toSerialize["state"] = o.State + } + toSerialize["artifactType"] = o.ArtifactType + return toSerialize, nil +} + +type NullableDocArtifactUpdate struct { + value *DocArtifactUpdate + isSet bool +} + +func (v NullableDocArtifactUpdate) Get() *DocArtifactUpdate { + return v.value +} + +func (v *NullableDocArtifactUpdate) Set(val *DocArtifactUpdate) { + v.value = val + v.isSet = true +} + +func (v NullableDocArtifactUpdate) IsSet() bool { + return v.isSet +} + +func (v *NullableDocArtifactUpdate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDocArtifactUpdate(val *DocArtifactUpdate) *NullableDocArtifactUpdate { + return &NullableDocArtifactUpdate{value: val, isSet: true} +} + +func (v NullableDocArtifactUpdate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDocArtifactUpdate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/openapi/model_model_artifact.go b/pkg/openapi/model_model_artifact.go index 17b3535b..f4b01a76 100644 --- a/pkg/openapi/model_model_artifact.go +++ b/pkg/openapi/model_model_artifact.go @@ -19,7 +19,6 @@ var _ MappedNullable = &ModelArtifact{} // ModelArtifact An ML model artifact. type ModelArtifact struct { - ArtifactType string `json:"artifactType"` // User provided custom properties which are not defined by its type. CustomProperties *map[string]MetadataValue `json:"customProperties,omitempty"` // An optional description about the resource. @@ -37,6 +36,7 @@ type ModelArtifact struct { CreateTimeSinceEpoch *string `json:"createTimeSinceEpoch,omitempty"` // Output only. Last update time of the resource since epoch in millisecond since epoch. LastUpdateTimeSinceEpoch *string `json:"lastUpdateTimeSinceEpoch,omitempty"` + ArtifactType string `json:"artifactType"` // Name of the model format. ModelFormatName *string `json:"modelFormatName,omitempty"` // Storage secret name. @@ -57,6 +57,7 @@ func NewModelArtifact(artifactType string) *ModelArtifact { this := ModelArtifact{} var state ArtifactState = ARTIFACTSTATE_UNKNOWN this.State = &state + this.ArtifactType = artifactType return &this } @@ -65,37 +66,13 @@ func NewModelArtifact(artifactType string) *ModelArtifact { // but it doesn't guarantee that properties required by API are set func NewModelArtifactWithDefaults() *ModelArtifact { this := ModelArtifact{} - var artifactType string = "model-artifact" - this.ArtifactType = artifactType var state ArtifactState = ARTIFACTSTATE_UNKNOWN this.State = &state + var artifactType string = "model-artifact" + this.ArtifactType = artifactType return &this } -// GetArtifactType returns the ArtifactType field value -func (o *ModelArtifact) GetArtifactType() string { - if o == nil { - var ret string - return ret - } - - return o.ArtifactType -} - -// GetArtifactTypeOk returns a tuple with the ArtifactType field value -// and a boolean to check if the value has been set. -func (o *ModelArtifact) GetArtifactTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ArtifactType, true -} - -// SetArtifactType sets field value -func (o *ModelArtifact) SetArtifactType(v string) { - o.ArtifactType = v -} - // GetCustomProperties returns the CustomProperties field value if set, zero value otherwise. func (o *ModelArtifact) GetCustomProperties() map[string]MetadataValue { if o == nil || IsNil(o.CustomProperties) { @@ -384,6 +361,30 @@ func (o *ModelArtifact) SetLastUpdateTimeSinceEpoch(v string) { o.LastUpdateTimeSinceEpoch = &v } +// GetArtifactType returns the ArtifactType field value +func (o *ModelArtifact) GetArtifactType() string { + if o == nil { + var ret string + return ret + } + + return o.ArtifactType +} + +// GetArtifactTypeOk returns a tuple with the ArtifactType field value +// and a boolean to check if the value has been set. +func (o *ModelArtifact) GetArtifactTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ArtifactType, true +} + +// SetArtifactType sets field value +func (o *ModelArtifact) SetArtifactType(v string) { + o.ArtifactType = v +} + // GetModelFormatName returns the ModelFormatName field value if set, zero value otherwise. func (o *ModelArtifact) GetModelFormatName() string { if o == nil || IsNil(o.ModelFormatName) { @@ -554,7 +555,6 @@ func (o ModelArtifact) MarshalJSON() ([]byte, error) { func (o ModelArtifact) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - toSerialize["artifactType"] = o.ArtifactType if !IsNil(o.CustomProperties) { toSerialize["customProperties"] = o.CustomProperties } @@ -582,6 +582,7 @@ func (o ModelArtifact) ToMap() (map[string]interface{}, error) { if !IsNil(o.LastUpdateTimeSinceEpoch) { toSerialize["lastUpdateTimeSinceEpoch"] = o.LastUpdateTimeSinceEpoch } + toSerialize["artifactType"] = o.ArtifactType if !IsNil(o.ModelFormatName) { toSerialize["modelFormatName"] = o.ModelFormatName } diff --git a/pkg/openapi/model_model_artifact_create.go b/pkg/openapi/model_model_artifact_create.go index 7a07fdb1..b5d2d606 100644 --- a/pkg/openapi/model_model_artifact_create.go +++ b/pkg/openapi/model_model_artifact_create.go @@ -29,7 +29,8 @@ type ModelArtifactCreate struct { Uri *string `json:"uri,omitempty"` State *ArtifactState `json:"state,omitempty"` // The client provided name of the artifact. This field is optional. If set, it must be unique among all the artifacts of the same artifact type within a database instance and cannot be changed once set. - Name *string `json:"name,omitempty"` + Name *string `json:"name,omitempty"` + ArtifactType string `json:"artifactType"` // Name of the model format. ModelFormatName *string `json:"modelFormatName,omitempty"` // Storage secret name. @@ -46,10 +47,11 @@ type ModelArtifactCreate struct { // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed -func NewModelArtifactCreate() *ModelArtifactCreate { +func NewModelArtifactCreate(artifactType string) *ModelArtifactCreate { this := ModelArtifactCreate{} var state ArtifactState = ARTIFACTSTATE_UNKNOWN this.State = &state + this.ArtifactType = artifactType return &this } @@ -60,6 +62,8 @@ func NewModelArtifactCreateWithDefaults() *ModelArtifactCreate { this := ModelArtifactCreate{} var state ArtifactState = ARTIFACTSTATE_UNKNOWN this.State = &state + var artifactType string = "model-artifact" + this.ArtifactType = artifactType return &this } @@ -255,6 +259,30 @@ func (o *ModelArtifactCreate) SetName(v string) { o.Name = &v } +// GetArtifactType returns the ArtifactType field value +func (o *ModelArtifactCreate) GetArtifactType() string { + if o == nil { + var ret string + return ret + } + + return o.ArtifactType +} + +// GetArtifactTypeOk returns a tuple with the ArtifactType field value +// and a boolean to check if the value has been set. +func (o *ModelArtifactCreate) GetArtifactTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ArtifactType, true +} + +// SetArtifactType sets field value +func (o *ModelArtifactCreate) SetArtifactType(v string) { + o.ArtifactType = v +} + // GetModelFormatName returns the ModelFormatName field value if set, zero value otherwise. func (o *ModelArtifactCreate) GetModelFormatName() string { if o == nil || IsNil(o.ModelFormatName) { @@ -443,6 +471,7 @@ func (o ModelArtifactCreate) ToMap() (map[string]interface{}, error) { if !IsNil(o.Name) { toSerialize["name"] = o.Name } + toSerialize["artifactType"] = o.ArtifactType if !IsNil(o.ModelFormatName) { toSerialize["modelFormatName"] = o.ModelFormatName } diff --git a/pkg/openapi/model_model_artifact_update.go b/pkg/openapi/model_model_artifact_update.go index dd154aa0..8e078b20 100644 --- a/pkg/openapi/model_model_artifact_update.go +++ b/pkg/openapi/model_model_artifact_update.go @@ -17,7 +17,7 @@ import ( // checks if the ModelArtifactUpdate type satisfies the MappedNullable interface at compile time var _ MappedNullable = &ModelArtifactUpdate{} -// ModelArtifactUpdate An ML model artifact. +// ModelArtifactUpdate An ML model artifact to be updated. type ModelArtifactUpdate struct { // User provided custom properties which are not defined by its type. CustomProperties *map[string]MetadataValue `json:"customProperties,omitempty"` @@ -26,8 +26,9 @@ type ModelArtifactUpdate struct { // The external id that come from the clients’ system. This field is optional. If set, it must be unique among all resources within a database instance. ExternalId *string `json:"externalId,omitempty"` // The uniform resource identifier of the physical artifact. May be empty if there is no physical artifact. - Uri *string `json:"uri,omitempty"` - State *ArtifactState `json:"state,omitempty"` + Uri *string `json:"uri,omitempty"` + State *ArtifactState `json:"state,omitempty"` + ArtifactType string `json:"artifactType"` // Name of the model format. ModelFormatName *string `json:"modelFormatName,omitempty"` // Storage secret name. @@ -44,10 +45,11 @@ type ModelArtifactUpdate struct { // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed -func NewModelArtifactUpdate() *ModelArtifactUpdate { +func NewModelArtifactUpdate(artifactType string) *ModelArtifactUpdate { this := ModelArtifactUpdate{} var state ArtifactState = ARTIFACTSTATE_UNKNOWN this.State = &state + this.ArtifactType = artifactType return &this } @@ -58,6 +60,8 @@ func NewModelArtifactUpdateWithDefaults() *ModelArtifactUpdate { this := ModelArtifactUpdate{} var state ArtifactState = ARTIFACTSTATE_UNKNOWN this.State = &state + var artifactType string = "model-artifact" + this.ArtifactType = artifactType return &this } @@ -221,6 +225,30 @@ func (o *ModelArtifactUpdate) SetState(v ArtifactState) { o.State = &v } +// GetArtifactType returns the ArtifactType field value +func (o *ModelArtifactUpdate) GetArtifactType() string { + if o == nil { + var ret string + return ret + } + + return o.ArtifactType +} + +// GetArtifactTypeOk returns a tuple with the ArtifactType field value +// and a boolean to check if the value has been set. +func (o *ModelArtifactUpdate) GetArtifactTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ArtifactType, true +} + +// SetArtifactType sets field value +func (o *ModelArtifactUpdate) SetArtifactType(v string) { + o.ArtifactType = v +} + // GetModelFormatName returns the ModelFormatName field value if set, zero value otherwise. func (o *ModelArtifactUpdate) GetModelFormatName() string { if o == nil || IsNil(o.ModelFormatName) { @@ -406,6 +434,7 @@ func (o ModelArtifactUpdate) ToMap() (map[string]interface{}, error) { if !IsNil(o.State) { toSerialize["state"] = o.State } + toSerialize["artifactType"] = o.ArtifactType if !IsNil(o.ModelFormatName) { toSerialize["modelFormatName"] = o.ModelFormatName } diff --git a/pkg/openapi/model_registered_model.go b/pkg/openapi/model_registered_model.go index 372fb3e8..1806e314 100644 --- a/pkg/openapi/model_registered_model.go +++ b/pkg/openapi/model_registered_model.go @@ -25,7 +25,7 @@ type RegisteredModel struct { Description *string `json:"description,omitempty"` // The external id that come from the clients’ system. This field is optional. If set, it must be unique among all resources within a database instance. ExternalId *string `json:"externalId,omitempty"` - // The client provided name of the artifact. This field is optional. If set, it must be unique among all the artifacts of the same artifact type within a database instance and cannot be changed once set. + // The client provided name of the model. It must be unique among all the RegisteredModels of the same type within a Model Registry instance and cannot be changed once set. Name string `json:"name"` // The unique server generated id of the resource. Id *string `json:"id,omitempty"` diff --git a/pkg/openapi/model_registered_model_create.go b/pkg/openapi/model_registered_model_create.go index 49edf663..8594df57 100644 --- a/pkg/openapi/model_registered_model_create.go +++ b/pkg/openapi/model_registered_model_create.go @@ -25,7 +25,7 @@ type RegisteredModelCreate struct { Description *string `json:"description,omitempty"` // The external id that come from the clients’ system. This field is optional. If set, it must be unique among all resources within a database instance. ExternalId *string `json:"externalId,omitempty"` - // The client provided name of the artifact. This field is optional. If set, it must be unique among all the artifacts of the same artifact type within a database instance and cannot be changed once set. + // The client provided name of the model. It must be unique among all the RegisteredModels of the same type within a Model Registry instance and cannot be changed once set. Name string `json:"name"` Owner *string `json:"owner,omitempty"` State *RegisteredModelState `json:"state,omitempty"` From e59a231b14a4f0e2ffc8a2b5e98a685272e2467e Mon Sep 17 00:00:00 2001 From: Isabella do Amaral Date: Fri, 20 Sep 2024 21:15:26 -0300 Subject: [PATCH 2/3] OAS: make discriminator explicit as model prop Signed-off-by: Isabella do Amaral --- api/openapi/model-registry.yaml | 46 +++++++++---- .../src/mr_openapi/models/doc_artifact.py | 2 +- .../mr_openapi/models/doc_artifact_create.py | 2 +- .../mr_openapi/models/doc_artifact_update.py | 12 +--- .../src/mr_openapi/models/model_artifact.py | 2 +- .../models/model_artifact_create.py | 2 +- .../models/model_artifact_update.py | 4 +- .../src/mr_openapi/models/registered_model.py | 2 +- .../models/registered_model_create.py | 2 +- .../generated/mlmd_openapi_converter.gen.go | 36 +++++----- .../generated/openapi_converter.gen.go | 10 +-- .../generated/openapi_reconciler.gen.go | 4 +- internal/server/openapi/type_asserts.go | 27 -------- patches/type_asserts.patch | 69 ------------------- pkg/openapi/model_doc_artifact.go | 57 ++++++++------- pkg/openapi/model_doc_artifact_create.go | 59 ++++++++-------- pkg/openapi/model_doc_artifact_update.go | 61 ++++++++-------- pkg/openapi/model_model_artifact.go | 57 ++++++++------- pkg/openapi/model_model_artifact_create.go | 59 ++++++++-------- pkg/openapi/model_model_artifact_update.go | 61 ++++++++-------- 20 files changed, 241 insertions(+), 333 deletions(-) diff --git a/api/openapi/model-registry.yaml b/api/openapi/model-registry.yaml index a18984c1..4a56dacf 100644 --- a/api/openapi/model-registry.yaml +++ b/api/openapi/model-registry.yaml @@ -1093,16 +1093,37 @@ components: type: string ModelArtifact: description: An ML model artifact. + type: object + required: + - artifactType + properties: + artifactType: + type: string + default: "model-artifact" allOf: - $ref: "#/components/schemas/BaseArtifact" - $ref: "#/components/schemas/ModelArtifactCreate" DocArtifact: description: A document. + type: object + required: + - artifactType + properties: + artifactType: + type: string + default: "doc-artifact" allOf: - $ref: "#/components/schemas/BaseArtifact" - $ref: "#/components/schemas/DocArtifactCreate" DocArtifactCreate: description: A document artifact to be created. + type: object + required: + - artifactType + properties: + artifactType: + type: string + default: "doc-artifact" allOf: - $ref: "#/components/schemas/BaseArtifactCreate" - $ref: "#/components/schemas/DocArtifactUpdate" @@ -1110,13 +1131,12 @@ components: description: A document artifact to be updated. required: - artifactType + properties: + artifactType: + type: string + default: "doc-artifact" allOf: - $ref: "#/components/schemas/BaseArtifactUpdate" - - type: object - properties: - artifactType: - type: string - default: "doc-artifact" RegisteredModel: description: A registered model in model registry. A registered model has ModelVersion children. allOf: @@ -1420,13 +1440,14 @@ components: description: An ML model artifact to be updated. required: - artifactType + properties: + artifactType: + type: string + default: "model-artifact" allOf: - $ref: "#/components/schemas/BaseArtifactUpdate" - type: object properties: - artifactType: - type: string - default: "model-artifact" modelFormatName: description: Name of the model format. type: string @@ -1446,14 +1467,13 @@ components: description: An ML model artifact. required: - artifactType + properties: + artifactType: + type: string + default: "model-artifact" allOf: - $ref: "#/components/schemas/BaseArtifactCreate" - $ref: "#/components/schemas/ModelArtifactUpdate" - - type: object - properties: - artifactType: - type: string - default: "model-artifact" Error: description: Error code and message. required: diff --git a/clients/python/src/mr_openapi/models/doc_artifact.py b/clients/python/src/mr_openapi/models/doc_artifact.py index f7d78350..631a7e0e 100644 --- a/clients/python/src/mr_openapi/models/doc_artifact.py +++ b/clients/python/src/mr_openapi/models/doc_artifact.py @@ -25,6 +25,7 @@ class DocArtifact(BaseModel): """A document.""" # noqa: E501 + artifact_type: StrictStr = Field(alias="artifactType") custom_properties: dict[str, MetadataValue] | None = Field( default=None, description="User provided custom properties which are not defined by its type.", @@ -56,7 +57,6 @@ class DocArtifact(BaseModel): description="Output only. Last update time of the resource since epoch in millisecond since epoch.", alias="lastUpdateTimeSinceEpoch", ) - artifact_type: StrictStr = Field(alias="artifactType") __properties: ClassVar[list[str]] = [ "customProperties", "description", diff --git a/clients/python/src/mr_openapi/models/doc_artifact_create.py b/clients/python/src/mr_openapi/models/doc_artifact_create.py index 9a977dd3..6537960d 100644 --- a/clients/python/src/mr_openapi/models/doc_artifact_create.py +++ b/clients/python/src/mr_openapi/models/doc_artifact_create.py @@ -25,6 +25,7 @@ class DocArtifactCreate(BaseModel): """A document artifact to be created.""" # noqa: E501 + artifact_type: StrictStr = Field(alias="artifactType") custom_properties: dict[str, MetadataValue] | None = Field( default=None, description="User provided custom properties which are not defined by its type.", @@ -45,7 +46,6 @@ class DocArtifactCreate(BaseModel): default=None, description="The client provided name of the artifact. This field is optional. If set, it must be unique among all the artifacts of the same artifact type within a database instance and cannot be changed once set.", ) - artifact_type: StrictStr = Field(alias="artifactType") __properties: ClassVar[list[str]] = [ "customProperties", "description", diff --git a/clients/python/src/mr_openapi/models/doc_artifact_update.py b/clients/python/src/mr_openapi/models/doc_artifact_update.py index 2461731f..682b2960 100644 --- a/clients/python/src/mr_openapi/models/doc_artifact_update.py +++ b/clients/python/src/mr_openapi/models/doc_artifact_update.py @@ -25,6 +25,7 @@ class DocArtifactUpdate(BaseModel): """A document artifact to be updated.""" # noqa: E501 + artifact_type: StrictStr = Field(alias="artifactType") custom_properties: dict[str, MetadataValue] | None = Field( default=None, description="User provided custom properties which are not defined by its type.", @@ -41,15 +42,7 @@ class DocArtifactUpdate(BaseModel): description="The uniform resource identifier of the physical artifact. May be empty if there is no physical artifact.", ) state: ArtifactState | None = None - artifact_type: StrictStr = Field(alias="artifactType") - __properties: ClassVar[list[str]] = [ - "customProperties", - "description", - "externalId", - "uri", - "state", - "artifactType", - ] + __properties: ClassVar[list[str]] = ["customProperties", "description", "externalId", "uri", "state"] model_config = ConfigDict( populate_by_name=True, @@ -117,6 +110,5 @@ def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: "externalId": obj.get("externalId"), "uri": obj.get("uri"), "state": obj.get("state"), - "artifactType": obj.get("artifactType") if obj.get("artifactType") is not None else "doc-artifact", } ) diff --git a/clients/python/src/mr_openapi/models/model_artifact.py b/clients/python/src/mr_openapi/models/model_artifact.py index a9e0e48b..6c0fa522 100644 --- a/clients/python/src/mr_openapi/models/model_artifact.py +++ b/clients/python/src/mr_openapi/models/model_artifact.py @@ -25,6 +25,7 @@ class ModelArtifact(BaseModel): """An ML model artifact.""" # noqa: E501 + artifact_type: StrictStr = Field(alias="artifactType") custom_properties: dict[str, MetadataValue] | None = Field( default=None, description="User provided custom properties which are not defined by its type.", @@ -56,7 +57,6 @@ class ModelArtifact(BaseModel): description="Output only. Last update time of the resource since epoch in millisecond since epoch.", alias="lastUpdateTimeSinceEpoch", ) - artifact_type: StrictStr = Field(alias="artifactType") model_format_name: StrictStr | None = Field( default=None, description="Name of the model format.", alias="modelFormatName" ) diff --git a/clients/python/src/mr_openapi/models/model_artifact_create.py b/clients/python/src/mr_openapi/models/model_artifact_create.py index a1bdfd99..0ba57c0d 100644 --- a/clients/python/src/mr_openapi/models/model_artifact_create.py +++ b/clients/python/src/mr_openapi/models/model_artifact_create.py @@ -25,6 +25,7 @@ class ModelArtifactCreate(BaseModel): """An ML model artifact.""" # noqa: E501 + artifact_type: StrictStr = Field(alias="artifactType") custom_properties: dict[str, MetadataValue] | None = Field( default=None, description="User provided custom properties which are not defined by its type.", @@ -45,7 +46,6 @@ class ModelArtifactCreate(BaseModel): default=None, description="The client provided name of the artifact. This field is optional. If set, it must be unique among all the artifacts of the same artifact type within a database instance and cannot be changed once set.", ) - artifact_type: StrictStr = Field(alias="artifactType") model_format_name: StrictStr | None = Field( default=None, description="Name of the model format.", alias="modelFormatName" ) diff --git a/clients/python/src/mr_openapi/models/model_artifact_update.py b/clients/python/src/mr_openapi/models/model_artifact_update.py index ff0ab582..6210b62d 100644 --- a/clients/python/src/mr_openapi/models/model_artifact_update.py +++ b/clients/python/src/mr_openapi/models/model_artifact_update.py @@ -25,6 +25,7 @@ class ModelArtifactUpdate(BaseModel): """An ML model artifact to be updated.""" # noqa: E501 + artifact_type: StrictStr = Field(alias="artifactType") custom_properties: dict[str, MetadataValue] | None = Field( default=None, description="User provided custom properties which are not defined by its type.", @@ -41,7 +42,6 @@ class ModelArtifactUpdate(BaseModel): description="The uniform resource identifier of the physical artifact. May be empty if there is no physical artifact.", ) state: ArtifactState | None = None - artifact_type: StrictStr = Field(alias="artifactType") model_format_name: StrictStr | None = Field( default=None, description="Name of the model format.", alias="modelFormatName" ) @@ -61,7 +61,6 @@ class ModelArtifactUpdate(BaseModel): "externalId", "uri", "state", - "artifactType", "modelFormatName", "storageKey", "storagePath", @@ -135,7 +134,6 @@ def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: "externalId": obj.get("externalId"), "uri": obj.get("uri"), "state": obj.get("state"), - "artifactType": obj.get("artifactType") if obj.get("artifactType") is not None else "model-artifact", "modelFormatName": obj.get("modelFormatName"), "storageKey": obj.get("storageKey"), "storagePath": obj.get("storagePath"), diff --git a/clients/python/src/mr_openapi/models/registered_model.py b/clients/python/src/mr_openapi/models/registered_model.py index 9bbe6c85..6ee032c9 100644 --- a/clients/python/src/mr_openapi/models/registered_model.py +++ b/clients/python/src/mr_openapi/models/registered_model.py @@ -37,7 +37,7 @@ class RegisteredModel(BaseModel): alias="externalId", ) name: StrictStr = Field( - description="The client provided name of the model. It must be unique among all the RegisteredModels of the same type within a Model Registry instance and cannot be changed once set." + description="The client provided name of the artifact. This field is optional. If set, it must be unique among all the artifacts of the same artifact type within a database instance and cannot be changed once set." ) id: StrictStr | None = Field(default=None, description="The unique server generated id of the resource.") create_time_since_epoch: StrictStr | None = Field( diff --git a/clients/python/src/mr_openapi/models/registered_model_create.py b/clients/python/src/mr_openapi/models/registered_model_create.py index 037ab793..29515e51 100644 --- a/clients/python/src/mr_openapi/models/registered_model_create.py +++ b/clients/python/src/mr_openapi/models/registered_model_create.py @@ -37,7 +37,7 @@ class RegisteredModelCreate(BaseModel): alias="externalId", ) name: StrictStr = Field( - description="The client provided name of the model. It must be unique among all the RegisteredModels of the same type within a Model Registry instance and cannot be changed once set." + description="The client provided name of the artifact. This field is optional. If set, it must be unique among all the artifacts of the same artifact type within a database instance and cannot be changed once set." ) owner: StrictStr | None = None state: RegisteredModelState | None = None diff --git a/internal/converter/generated/mlmd_openapi_converter.gen.go b/internal/converter/generated/mlmd_openapi_converter.gen.go index 5b42bd0d..e140392c 100644 --- a/internal/converter/generated/mlmd_openapi_converter.gen.go +++ b/internal/converter/generated/mlmd_openapi_converter.gen.go @@ -16,6 +16,11 @@ func (c *MLMDToOpenAPIConverterImpl) ConvertDocArtifact(source *proto.Artifact) var pOpenapiDocArtifact *openapi.DocArtifact if source != nil { var openapiDocArtifact openapi.DocArtifact + xstring, err := converter.MapArtifactType(source) + if err != nil { + return nil, fmt.Errorf("error setting field ArtifactType: %w", err) + } + openapiDocArtifact.ArtifactType = xstring mapStringOpenapiMetadataValue, err := converter.MapMLMDCustomProperties((*source).CustomProperties) if err != nil { return nil, fmt.Errorf("error setting field CustomProperties: %w", err) @@ -23,23 +28,18 @@ func (c *MLMDToOpenAPIConverterImpl) ConvertDocArtifact(source *proto.Artifact) openapiDocArtifact.CustomProperties = &mapStringOpenapiMetadataValue openapiDocArtifact.Description = converter.MapDescription((*source).Properties) if (*source).ExternalId != nil { - xstring := *(*source).ExternalId - openapiDocArtifact.ExternalId = &xstring + xstring2 := *(*source).ExternalId + openapiDocArtifact.ExternalId = &xstring2 } if (*source).Uri != nil { - xstring2 := *(*source).Uri - openapiDocArtifact.Uri = &xstring2 + xstring3 := *(*source).Uri + openapiDocArtifact.Uri = &xstring3 } openapiDocArtifact.State = converter.MapMLMDArtifactState((*source).State) openapiDocArtifact.Name = converter.MapNameFromOwned((*source).Name) openapiDocArtifact.Id = converter.Int64ToString((*source).Id) openapiDocArtifact.CreateTimeSinceEpoch = converter.Int64ToString((*source).CreateTimeSinceEpoch) openapiDocArtifact.LastUpdateTimeSinceEpoch = converter.Int64ToString((*source).LastUpdateTimeSinceEpoch) - xstring3, err := converter.MapArtifactType(source) - if err != nil { - return nil, fmt.Errorf("error setting field ArtifactType: %w", err) - } - openapiDocArtifact.ArtifactType = xstring3 pOpenapiDocArtifact = &openapiDocArtifact } return pOpenapiDocArtifact, nil @@ -75,6 +75,11 @@ func (c *MLMDToOpenAPIConverterImpl) ConvertModelArtifact(source *proto.Artifact var pOpenapiModelArtifact *openapi.ModelArtifact if source != nil { var openapiModelArtifact openapi.ModelArtifact + xstring, err := converter.MapArtifactType(source) + if err != nil { + return nil, fmt.Errorf("error setting field ArtifactType: %w", err) + } + openapiModelArtifact.ArtifactType = xstring mapStringOpenapiMetadataValue, err := converter.MapMLMDCustomProperties((*source).CustomProperties) if err != nil { return nil, fmt.Errorf("error setting field CustomProperties: %w", err) @@ -82,23 +87,18 @@ func (c *MLMDToOpenAPIConverterImpl) ConvertModelArtifact(source *proto.Artifact openapiModelArtifact.CustomProperties = &mapStringOpenapiMetadataValue openapiModelArtifact.Description = converter.MapDescription((*source).Properties) if (*source).ExternalId != nil { - xstring := *(*source).ExternalId - openapiModelArtifact.ExternalId = &xstring + xstring2 := *(*source).ExternalId + openapiModelArtifact.ExternalId = &xstring2 } if (*source).Uri != nil { - xstring2 := *(*source).Uri - openapiModelArtifact.Uri = &xstring2 + xstring3 := *(*source).Uri + openapiModelArtifact.Uri = &xstring3 } openapiModelArtifact.State = converter.MapMLMDArtifactState((*source).State) openapiModelArtifact.Name = converter.MapNameFromOwned((*source).Name) openapiModelArtifact.Id = converter.Int64ToString((*source).Id) openapiModelArtifact.CreateTimeSinceEpoch = converter.Int64ToString((*source).CreateTimeSinceEpoch) openapiModelArtifact.LastUpdateTimeSinceEpoch = converter.Int64ToString((*source).LastUpdateTimeSinceEpoch) - xstring3, err := converter.MapArtifactType(source) - if err != nil { - return nil, fmt.Errorf("error setting field ArtifactType: %w", err) - } - openapiModelArtifact.ArtifactType = xstring3 openapiModelArtifact.ModelFormatName = converter.MapModelArtifactFormatName((*source).Properties) openapiModelArtifact.StorageKey = converter.MapModelArtifactStorageKey((*source).Properties) openapiModelArtifact.StoragePath = converter.MapModelArtifactStoragePath((*source).Properties) diff --git a/internal/converter/generated/openapi_converter.gen.go b/internal/converter/generated/openapi_converter.gen.go index 24d1ba49..d98c0916 100644 --- a/internal/converter/generated/openapi_converter.gen.go +++ b/internal/converter/generated/openapi_converter.gen.go @@ -649,18 +649,18 @@ func (c *OpenAPIConverterImpl) OverrideNotEditableForModelArtifact(source conver openapiModelArtifact := converter.InitWithUpdate(source) var pString *string if source.Existing != nil { - pString = source.Existing.Name + pString = &source.Existing.ArtifactType } if pString != nil { - xstring := *pString - openapiModelArtifact.Name = &xstring + openapiModelArtifact.ArtifactType = *pString } var pString2 *string if source.Existing != nil { - pString2 = &source.Existing.ArtifactType + pString2 = source.Existing.Name } if pString2 != nil { - openapiModelArtifact.ArtifactType = *pString2 + xstring := *pString2 + openapiModelArtifact.Name = &xstring } return openapiModelArtifact, nil } diff --git a/internal/converter/generated/openapi_reconciler.gen.go b/internal/converter/generated/openapi_reconciler.gen.go index 13497b14..cdb8d75a 100644 --- a/internal/converter/generated/openapi_reconciler.gen.go +++ b/internal/converter/generated/openapi_reconciler.gen.go @@ -519,6 +519,7 @@ func (c *OpenAPIReconcilerImpl) pOpenapiDocArtifactToPOpenapiDocArtifact(source var pOpenapiDocArtifact *openapi.DocArtifact if source != nil { var openapiDocArtifact openapi.DocArtifact + openapiDocArtifact.ArtifactType = (*source).ArtifactType if (*source).CustomProperties != nil { var mapStringOpenapiMetadataValue map[string]openapi.MetadataValue if (*(*source).CustomProperties) != nil { @@ -564,7 +565,6 @@ func (c *OpenAPIReconcilerImpl) pOpenapiDocArtifactToPOpenapiDocArtifact(source xstring7 := *(*source).LastUpdateTimeSinceEpoch openapiDocArtifact.LastUpdateTimeSinceEpoch = &xstring7 } - openapiDocArtifact.ArtifactType = (*source).ArtifactType pOpenapiDocArtifact = &openapiDocArtifact } return pOpenapiDocArtifact, nil @@ -634,6 +634,7 @@ func (c *OpenAPIReconcilerImpl) pOpenapiModelArtifactToPOpenapiModelArtifact(sou var pOpenapiModelArtifact *openapi.ModelArtifact if source != nil { var openapiModelArtifact openapi.ModelArtifact + openapiModelArtifact.ArtifactType = (*source).ArtifactType if (*source).CustomProperties != nil { var mapStringOpenapiMetadataValue map[string]openapi.MetadataValue if (*(*source).CustomProperties) != nil { @@ -679,7 +680,6 @@ func (c *OpenAPIReconcilerImpl) pOpenapiModelArtifactToPOpenapiModelArtifact(sou xstring7 := *(*source).LastUpdateTimeSinceEpoch openapiModelArtifact.LastUpdateTimeSinceEpoch = &xstring7 } - openapiModelArtifact.ArtifactType = (*source).ArtifactType if (*source).ModelFormatName != nil { xstring8 := *(*source).ModelFormatName openapiModelArtifact.ModelFormatName = &xstring8 diff --git a/internal/server/openapi/type_asserts.go b/internal/server/openapi/type_asserts.go index c453bd40..63395c6a 100644 --- a/internal/server/openapi/type_asserts.go +++ b/internal/server/openapi/type_asserts.go @@ -28,15 +28,6 @@ func AssertArtifactCreateConstraints(obj model.ArtifactCreate) error { // AssertArtifactCreateRequired checks if the required fields are not zero-ed func AssertArtifactCreateRequired(obj model.ArtifactCreate) error { - // elements := map[string]interface{}{ - // "artifactType": obj.ArtifactType, - // } - // for name, el := range elements { - // if isZero := IsZeroValue(el); isZero { - // return &RequiredError{Field: name} - // } - // } - return nil } @@ -68,15 +59,6 @@ func AssertArtifactListRequired(obj model.ArtifactList) error { // AssertArtifactRequired checks if the required fields are not zero-ed func AssertArtifactRequired(obj model.Artifact) error { - // elements := map[string]interface{}{ - // "artifactType": obj.ArtifactType, - // } - // for name, el := range elements { - // if isZero := IsZeroValue(el); isZero { - // return &RequiredError{Field: name} - // } - // } - return nil } @@ -97,15 +79,6 @@ func AssertArtifactUpdateConstraints(obj model.ArtifactUpdate) error { // AssertArtifactUpdateRequired checks if the required fields are not zero-ed func AssertArtifactUpdateRequired(obj model.ArtifactUpdate) error { - // elements := map[string]interface{}{ - // "artifactType": obj.ArtifactType, - // } - // for name, el := range elements { - // if isZero := IsZeroValue(el); isZero { - // return &RequiredError{Field: name} - // } - // } - return nil } diff --git a/patches/type_asserts.patch b/patches/type_asserts.patch index 037aaa67..485878a1 100644 --- a/patches/type_asserts.patch +++ b/patches/type_asserts.patch @@ -2,75 +2,6 @@ diff --git a/internal/server/openapi/type_asserts.go b/internal/server/openapi/t index b001018..9907fbc 100644 --- a/internal/server/openapi/type_asserts.go +++ b/internal/server/openapi/type_asserts.go -@@ -28,14 +28,14 @@ func AssertArtifactCreateConstraints(obj model.ArtifactCreate) error { - - // AssertArtifactCreateRequired checks if the required fields are not zero-ed - func AssertArtifactCreateRequired(obj model.ArtifactCreate) error { -- elements := map[string]interface{}{ -- "artifactType": obj.ArtifactType, -- } -- for name, el := range elements { -- if isZero := IsZeroValue(el); isZero { -- return &RequiredError{Field: name} -- } -- } -+ // elements := map[string]interface{}{ -+ // "artifactType": obj.ArtifactType, -+ // } -+ // for name, el := range elements { -+ // if isZero := IsZeroValue(el); isZero { -+ // return &RequiredError{Field: name} -+ // } -+ // } - - return nil - } -@@ -68,14 +68,14 @@ func AssertArtifactListRequired(obj model.ArtifactList) error { - - // AssertArtifactRequired checks if the required fields are not zero-ed - func AssertArtifactRequired(obj model.Artifact) error { -- elements := map[string]interface{}{ -- "artifactType": obj.ArtifactType, -- } -- for name, el := range elements { -- if isZero := IsZeroValue(el); isZero { -- return &RequiredError{Field: name} -- } -- } -+ // elements := map[string]interface{}{ -+ // "artifactType": obj.ArtifactType, -+ // } -+ // for name, el := range elements { -+ // if isZero := IsZeroValue(el); isZero { -+ // return &RequiredError{Field: name} -+ // } -+ // } - - return nil - } -@@ -97,14 +97,14 @@ func AssertArtifactUpdateConstraints(obj model.ArtifactUpdate) error { - - // AssertArtifactUpdateRequired checks if the required fields are not zero-ed - func AssertArtifactUpdateRequired(obj model.ArtifactUpdate) error { -- elements := map[string]interface{}{ -- "artifactType": obj.ArtifactType, -- } -- for name, el := range elements { -- if isZero := IsZeroValue(el); isZero { -- return &RequiredError{Field: name} -- } -- } -+ // elements := map[string]interface{}{ -+ // "artifactType": obj.ArtifactType, -+ // } -+ // for name, el := range elements { -+ // if isZero := IsZeroValue(el); isZero { -+ // return &RequiredError{Field: name} -+ // } -+ // } - - return nil - } @@ -449,21 +449,22 @@ func AssertMetadataStructValueConstraints(obj model.MetadataStructValue) error { // AssertMetadataValueRequired checks if the required fields are not zero-ed diff --git a/pkg/openapi/model_doc_artifact.go b/pkg/openapi/model_doc_artifact.go index 8337fa16..2396dc48 100644 --- a/pkg/openapi/model_doc_artifact.go +++ b/pkg/openapi/model_doc_artifact.go @@ -19,6 +19,7 @@ var _ MappedNullable = &DocArtifact{} // DocArtifact A document. type DocArtifact struct { + ArtifactType string `json:"artifactType"` // User provided custom properties which are not defined by its type. CustomProperties *map[string]MetadataValue `json:"customProperties,omitempty"` // An optional description about the resource. @@ -36,7 +37,6 @@ type DocArtifact struct { CreateTimeSinceEpoch *string `json:"createTimeSinceEpoch,omitempty"` // Output only. Last update time of the resource since epoch in millisecond since epoch. LastUpdateTimeSinceEpoch *string `json:"lastUpdateTimeSinceEpoch,omitempty"` - ArtifactType string `json:"artifactType"` } // NewDocArtifact instantiates a new DocArtifact object @@ -47,7 +47,6 @@ func NewDocArtifact(artifactType string) *DocArtifact { this := DocArtifact{} var state ArtifactState = ARTIFACTSTATE_UNKNOWN this.State = &state - this.ArtifactType = artifactType return &this } @@ -56,13 +55,37 @@ func NewDocArtifact(artifactType string) *DocArtifact { // but it doesn't guarantee that properties required by API are set func NewDocArtifactWithDefaults() *DocArtifact { this := DocArtifact{} - var state ArtifactState = ARTIFACTSTATE_UNKNOWN - this.State = &state var artifactType string = "doc-artifact" this.ArtifactType = artifactType + var state ArtifactState = ARTIFACTSTATE_UNKNOWN + this.State = &state return &this } +// GetArtifactType returns the ArtifactType field value +func (o *DocArtifact) GetArtifactType() string { + if o == nil { + var ret string + return ret + } + + return o.ArtifactType +} + +// GetArtifactTypeOk returns a tuple with the ArtifactType field value +// and a boolean to check if the value has been set. +func (o *DocArtifact) GetArtifactTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ArtifactType, true +} + +// SetArtifactType sets field value +func (o *DocArtifact) SetArtifactType(v string) { + o.ArtifactType = v +} + // GetCustomProperties returns the CustomProperties field value if set, zero value otherwise. func (o *DocArtifact) GetCustomProperties() map[string]MetadataValue { if o == nil || IsNil(o.CustomProperties) { @@ -351,30 +374,6 @@ func (o *DocArtifact) SetLastUpdateTimeSinceEpoch(v string) { o.LastUpdateTimeSinceEpoch = &v } -// GetArtifactType returns the ArtifactType field value -func (o *DocArtifact) GetArtifactType() string { - if o == nil { - var ret string - return ret - } - - return o.ArtifactType -} - -// GetArtifactTypeOk returns a tuple with the ArtifactType field value -// and a boolean to check if the value has been set. -func (o *DocArtifact) GetArtifactTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ArtifactType, true -} - -// SetArtifactType sets field value -func (o *DocArtifact) SetArtifactType(v string) { - o.ArtifactType = v -} - func (o DocArtifact) MarshalJSON() ([]byte, error) { toSerialize, err := o.ToMap() if err != nil { @@ -385,6 +384,7 @@ func (o DocArtifact) MarshalJSON() ([]byte, error) { func (o DocArtifact) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} + toSerialize["artifactType"] = o.ArtifactType if !IsNil(o.CustomProperties) { toSerialize["customProperties"] = o.CustomProperties } @@ -412,7 +412,6 @@ func (o DocArtifact) ToMap() (map[string]interface{}, error) { if !IsNil(o.LastUpdateTimeSinceEpoch) { toSerialize["lastUpdateTimeSinceEpoch"] = o.LastUpdateTimeSinceEpoch } - toSerialize["artifactType"] = o.ArtifactType return toSerialize, nil } diff --git a/pkg/openapi/model_doc_artifact_create.go b/pkg/openapi/model_doc_artifact_create.go index 3f719de3..07e4240a 100644 --- a/pkg/openapi/model_doc_artifact_create.go +++ b/pkg/openapi/model_doc_artifact_create.go @@ -19,6 +19,7 @@ var _ MappedNullable = &DocArtifactCreate{} // DocArtifactCreate A document artifact to be created. type DocArtifactCreate struct { + ArtifactType string `json:"artifactType"` // User provided custom properties which are not defined by its type. CustomProperties *map[string]MetadataValue `json:"customProperties,omitempty"` // An optional description about the resource. @@ -29,8 +30,7 @@ type DocArtifactCreate struct { Uri *string `json:"uri,omitempty"` State *ArtifactState `json:"state,omitempty"` // The client provided name of the artifact. This field is optional. If set, it must be unique among all the artifacts of the same artifact type within a database instance and cannot be changed once set. - Name *string `json:"name,omitempty"` - ArtifactType string `json:"artifactType"` + Name *string `json:"name,omitempty"` } // NewDocArtifactCreate instantiates a new DocArtifactCreate object @@ -41,7 +41,6 @@ func NewDocArtifactCreate(artifactType string) *DocArtifactCreate { this := DocArtifactCreate{} var state ArtifactState = ARTIFACTSTATE_UNKNOWN this.State = &state - this.ArtifactType = artifactType return &this } @@ -50,13 +49,37 @@ func NewDocArtifactCreate(artifactType string) *DocArtifactCreate { // but it doesn't guarantee that properties required by API are set func NewDocArtifactCreateWithDefaults() *DocArtifactCreate { this := DocArtifactCreate{} - var state ArtifactState = ARTIFACTSTATE_UNKNOWN - this.State = &state var artifactType string = "doc-artifact" this.ArtifactType = artifactType + var state ArtifactState = ARTIFACTSTATE_UNKNOWN + this.State = &state return &this } +// GetArtifactType returns the ArtifactType field value +func (o *DocArtifactCreate) GetArtifactType() string { + if o == nil { + var ret string + return ret + } + + return o.ArtifactType +} + +// GetArtifactTypeOk returns a tuple with the ArtifactType field value +// and a boolean to check if the value has been set. +func (o *DocArtifactCreate) GetArtifactTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ArtifactType, true +} + +// SetArtifactType sets field value +func (o *DocArtifactCreate) SetArtifactType(v string) { + o.ArtifactType = v +} + // GetCustomProperties returns the CustomProperties field value if set, zero value otherwise. func (o *DocArtifactCreate) GetCustomProperties() map[string]MetadataValue { if o == nil || IsNil(o.CustomProperties) { @@ -249,30 +272,6 @@ func (o *DocArtifactCreate) SetName(v string) { o.Name = &v } -// GetArtifactType returns the ArtifactType field value -func (o *DocArtifactCreate) GetArtifactType() string { - if o == nil { - var ret string - return ret - } - - return o.ArtifactType -} - -// GetArtifactTypeOk returns a tuple with the ArtifactType field value -// and a boolean to check if the value has been set. -func (o *DocArtifactCreate) GetArtifactTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ArtifactType, true -} - -// SetArtifactType sets field value -func (o *DocArtifactCreate) SetArtifactType(v string) { - o.ArtifactType = v -} - func (o DocArtifactCreate) MarshalJSON() ([]byte, error) { toSerialize, err := o.ToMap() if err != nil { @@ -283,6 +282,7 @@ func (o DocArtifactCreate) MarshalJSON() ([]byte, error) { func (o DocArtifactCreate) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} + toSerialize["artifactType"] = o.ArtifactType if !IsNil(o.CustomProperties) { toSerialize["customProperties"] = o.CustomProperties } @@ -301,7 +301,6 @@ func (o DocArtifactCreate) ToMap() (map[string]interface{}, error) { if !IsNil(o.Name) { toSerialize["name"] = o.Name } - toSerialize["artifactType"] = o.ArtifactType return toSerialize, nil } diff --git a/pkg/openapi/model_doc_artifact_update.go b/pkg/openapi/model_doc_artifact_update.go index e8337b36..cee15785 100644 --- a/pkg/openapi/model_doc_artifact_update.go +++ b/pkg/openapi/model_doc_artifact_update.go @@ -19,6 +19,7 @@ var _ MappedNullable = &DocArtifactUpdate{} // DocArtifactUpdate A document artifact to be updated. type DocArtifactUpdate struct { + ArtifactType string `json:"artifactType"` // User provided custom properties which are not defined by its type. CustomProperties *map[string]MetadataValue `json:"customProperties,omitempty"` // An optional description about the resource. @@ -26,9 +27,8 @@ type DocArtifactUpdate struct { // The external id that come from the clients’ system. This field is optional. If set, it must be unique among all resources within a database instance. ExternalId *string `json:"externalId,omitempty"` // The uniform resource identifier of the physical artifact. May be empty if there is no physical artifact. - Uri *string `json:"uri,omitempty"` - State *ArtifactState `json:"state,omitempty"` - ArtifactType string `json:"artifactType"` + Uri *string `json:"uri,omitempty"` + State *ArtifactState `json:"state,omitempty"` } // NewDocArtifactUpdate instantiates a new DocArtifactUpdate object @@ -39,7 +39,6 @@ func NewDocArtifactUpdate(artifactType string) *DocArtifactUpdate { this := DocArtifactUpdate{} var state ArtifactState = ARTIFACTSTATE_UNKNOWN this.State = &state - this.ArtifactType = artifactType return &this } @@ -48,13 +47,37 @@ func NewDocArtifactUpdate(artifactType string) *DocArtifactUpdate { // but it doesn't guarantee that properties required by API are set func NewDocArtifactUpdateWithDefaults() *DocArtifactUpdate { this := DocArtifactUpdate{} - var state ArtifactState = ARTIFACTSTATE_UNKNOWN - this.State = &state var artifactType string = "doc-artifact" this.ArtifactType = artifactType + var state ArtifactState = ARTIFACTSTATE_UNKNOWN + this.State = &state return &this } +// GetArtifactType returns the ArtifactType field value +func (o *DocArtifactUpdate) GetArtifactType() string { + if o == nil { + var ret string + return ret + } + + return o.ArtifactType +} + +// GetArtifactTypeOk returns a tuple with the ArtifactType field value +// and a boolean to check if the value has been set. +func (o *DocArtifactUpdate) GetArtifactTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ArtifactType, true +} + +// SetArtifactType sets field value +func (o *DocArtifactUpdate) SetArtifactType(v string) { + o.ArtifactType = v +} + // GetCustomProperties returns the CustomProperties field value if set, zero value otherwise. func (o *DocArtifactUpdate) GetCustomProperties() map[string]MetadataValue { if o == nil || IsNil(o.CustomProperties) { @@ -215,30 +238,6 @@ func (o *DocArtifactUpdate) SetState(v ArtifactState) { o.State = &v } -// GetArtifactType returns the ArtifactType field value -func (o *DocArtifactUpdate) GetArtifactType() string { - if o == nil { - var ret string - return ret - } - - return o.ArtifactType -} - -// GetArtifactTypeOk returns a tuple with the ArtifactType field value -// and a boolean to check if the value has been set. -func (o *DocArtifactUpdate) GetArtifactTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ArtifactType, true -} - -// SetArtifactType sets field value -func (o *DocArtifactUpdate) SetArtifactType(v string) { - o.ArtifactType = v -} - func (o DocArtifactUpdate) MarshalJSON() ([]byte, error) { toSerialize, err := o.ToMap() if err != nil { @@ -249,6 +248,7 @@ func (o DocArtifactUpdate) MarshalJSON() ([]byte, error) { func (o DocArtifactUpdate) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} + toSerialize["artifactType"] = o.ArtifactType if !IsNil(o.CustomProperties) { toSerialize["customProperties"] = o.CustomProperties } @@ -264,7 +264,6 @@ func (o DocArtifactUpdate) ToMap() (map[string]interface{}, error) { if !IsNil(o.State) { toSerialize["state"] = o.State } - toSerialize["artifactType"] = o.ArtifactType return toSerialize, nil } diff --git a/pkg/openapi/model_model_artifact.go b/pkg/openapi/model_model_artifact.go index f4b01a76..17b3535b 100644 --- a/pkg/openapi/model_model_artifact.go +++ b/pkg/openapi/model_model_artifact.go @@ -19,6 +19,7 @@ var _ MappedNullable = &ModelArtifact{} // ModelArtifact An ML model artifact. type ModelArtifact struct { + ArtifactType string `json:"artifactType"` // User provided custom properties which are not defined by its type. CustomProperties *map[string]MetadataValue `json:"customProperties,omitempty"` // An optional description about the resource. @@ -36,7 +37,6 @@ type ModelArtifact struct { CreateTimeSinceEpoch *string `json:"createTimeSinceEpoch,omitempty"` // Output only. Last update time of the resource since epoch in millisecond since epoch. LastUpdateTimeSinceEpoch *string `json:"lastUpdateTimeSinceEpoch,omitempty"` - ArtifactType string `json:"artifactType"` // Name of the model format. ModelFormatName *string `json:"modelFormatName,omitempty"` // Storage secret name. @@ -57,7 +57,6 @@ func NewModelArtifact(artifactType string) *ModelArtifact { this := ModelArtifact{} var state ArtifactState = ARTIFACTSTATE_UNKNOWN this.State = &state - this.ArtifactType = artifactType return &this } @@ -66,13 +65,37 @@ func NewModelArtifact(artifactType string) *ModelArtifact { // but it doesn't guarantee that properties required by API are set func NewModelArtifactWithDefaults() *ModelArtifact { this := ModelArtifact{} - var state ArtifactState = ARTIFACTSTATE_UNKNOWN - this.State = &state var artifactType string = "model-artifact" this.ArtifactType = artifactType + var state ArtifactState = ARTIFACTSTATE_UNKNOWN + this.State = &state return &this } +// GetArtifactType returns the ArtifactType field value +func (o *ModelArtifact) GetArtifactType() string { + if o == nil { + var ret string + return ret + } + + return o.ArtifactType +} + +// GetArtifactTypeOk returns a tuple with the ArtifactType field value +// and a boolean to check if the value has been set. +func (o *ModelArtifact) GetArtifactTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ArtifactType, true +} + +// SetArtifactType sets field value +func (o *ModelArtifact) SetArtifactType(v string) { + o.ArtifactType = v +} + // GetCustomProperties returns the CustomProperties field value if set, zero value otherwise. func (o *ModelArtifact) GetCustomProperties() map[string]MetadataValue { if o == nil || IsNil(o.CustomProperties) { @@ -361,30 +384,6 @@ func (o *ModelArtifact) SetLastUpdateTimeSinceEpoch(v string) { o.LastUpdateTimeSinceEpoch = &v } -// GetArtifactType returns the ArtifactType field value -func (o *ModelArtifact) GetArtifactType() string { - if o == nil { - var ret string - return ret - } - - return o.ArtifactType -} - -// GetArtifactTypeOk returns a tuple with the ArtifactType field value -// and a boolean to check if the value has been set. -func (o *ModelArtifact) GetArtifactTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ArtifactType, true -} - -// SetArtifactType sets field value -func (o *ModelArtifact) SetArtifactType(v string) { - o.ArtifactType = v -} - // GetModelFormatName returns the ModelFormatName field value if set, zero value otherwise. func (o *ModelArtifact) GetModelFormatName() string { if o == nil || IsNil(o.ModelFormatName) { @@ -555,6 +554,7 @@ func (o ModelArtifact) MarshalJSON() ([]byte, error) { func (o ModelArtifact) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} + toSerialize["artifactType"] = o.ArtifactType if !IsNil(o.CustomProperties) { toSerialize["customProperties"] = o.CustomProperties } @@ -582,7 +582,6 @@ func (o ModelArtifact) ToMap() (map[string]interface{}, error) { if !IsNil(o.LastUpdateTimeSinceEpoch) { toSerialize["lastUpdateTimeSinceEpoch"] = o.LastUpdateTimeSinceEpoch } - toSerialize["artifactType"] = o.ArtifactType if !IsNil(o.ModelFormatName) { toSerialize["modelFormatName"] = o.ModelFormatName } diff --git a/pkg/openapi/model_model_artifact_create.go b/pkg/openapi/model_model_artifact_create.go index b5d2d606..b4498baa 100644 --- a/pkg/openapi/model_model_artifact_create.go +++ b/pkg/openapi/model_model_artifact_create.go @@ -19,6 +19,7 @@ var _ MappedNullable = &ModelArtifactCreate{} // ModelArtifactCreate An ML model artifact. type ModelArtifactCreate struct { + ArtifactType string `json:"artifactType"` // User provided custom properties which are not defined by its type. CustomProperties *map[string]MetadataValue `json:"customProperties,omitempty"` // An optional description about the resource. @@ -29,8 +30,7 @@ type ModelArtifactCreate struct { Uri *string `json:"uri,omitempty"` State *ArtifactState `json:"state,omitempty"` // The client provided name of the artifact. This field is optional. If set, it must be unique among all the artifacts of the same artifact type within a database instance and cannot be changed once set. - Name *string `json:"name,omitempty"` - ArtifactType string `json:"artifactType"` + Name *string `json:"name,omitempty"` // Name of the model format. ModelFormatName *string `json:"modelFormatName,omitempty"` // Storage secret name. @@ -51,7 +51,6 @@ func NewModelArtifactCreate(artifactType string) *ModelArtifactCreate { this := ModelArtifactCreate{} var state ArtifactState = ARTIFACTSTATE_UNKNOWN this.State = &state - this.ArtifactType = artifactType return &this } @@ -60,13 +59,37 @@ func NewModelArtifactCreate(artifactType string) *ModelArtifactCreate { // but it doesn't guarantee that properties required by API are set func NewModelArtifactCreateWithDefaults() *ModelArtifactCreate { this := ModelArtifactCreate{} - var state ArtifactState = ARTIFACTSTATE_UNKNOWN - this.State = &state var artifactType string = "model-artifact" this.ArtifactType = artifactType + var state ArtifactState = ARTIFACTSTATE_UNKNOWN + this.State = &state return &this } +// GetArtifactType returns the ArtifactType field value +func (o *ModelArtifactCreate) GetArtifactType() string { + if o == nil { + var ret string + return ret + } + + return o.ArtifactType +} + +// GetArtifactTypeOk returns a tuple with the ArtifactType field value +// and a boolean to check if the value has been set. +func (o *ModelArtifactCreate) GetArtifactTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ArtifactType, true +} + +// SetArtifactType sets field value +func (o *ModelArtifactCreate) SetArtifactType(v string) { + o.ArtifactType = v +} + // GetCustomProperties returns the CustomProperties field value if set, zero value otherwise. func (o *ModelArtifactCreate) GetCustomProperties() map[string]MetadataValue { if o == nil || IsNil(o.CustomProperties) { @@ -259,30 +282,6 @@ func (o *ModelArtifactCreate) SetName(v string) { o.Name = &v } -// GetArtifactType returns the ArtifactType field value -func (o *ModelArtifactCreate) GetArtifactType() string { - if o == nil { - var ret string - return ret - } - - return o.ArtifactType -} - -// GetArtifactTypeOk returns a tuple with the ArtifactType field value -// and a boolean to check if the value has been set. -func (o *ModelArtifactCreate) GetArtifactTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ArtifactType, true -} - -// SetArtifactType sets field value -func (o *ModelArtifactCreate) SetArtifactType(v string) { - o.ArtifactType = v -} - // GetModelFormatName returns the ModelFormatName field value if set, zero value otherwise. func (o *ModelArtifactCreate) GetModelFormatName() string { if o == nil || IsNil(o.ModelFormatName) { @@ -453,6 +452,7 @@ func (o ModelArtifactCreate) MarshalJSON() ([]byte, error) { func (o ModelArtifactCreate) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} + toSerialize["artifactType"] = o.ArtifactType if !IsNil(o.CustomProperties) { toSerialize["customProperties"] = o.CustomProperties } @@ -471,7 +471,6 @@ func (o ModelArtifactCreate) ToMap() (map[string]interface{}, error) { if !IsNil(o.Name) { toSerialize["name"] = o.Name } - toSerialize["artifactType"] = o.ArtifactType if !IsNil(o.ModelFormatName) { toSerialize["modelFormatName"] = o.ModelFormatName } diff --git a/pkg/openapi/model_model_artifact_update.go b/pkg/openapi/model_model_artifact_update.go index 8e078b20..a555d498 100644 --- a/pkg/openapi/model_model_artifact_update.go +++ b/pkg/openapi/model_model_artifact_update.go @@ -19,6 +19,7 @@ var _ MappedNullable = &ModelArtifactUpdate{} // ModelArtifactUpdate An ML model artifact to be updated. type ModelArtifactUpdate struct { + ArtifactType string `json:"artifactType"` // User provided custom properties which are not defined by its type. CustomProperties *map[string]MetadataValue `json:"customProperties,omitempty"` // An optional description about the resource. @@ -26,9 +27,8 @@ type ModelArtifactUpdate struct { // The external id that come from the clients’ system. This field is optional. If set, it must be unique among all resources within a database instance. ExternalId *string `json:"externalId,omitempty"` // The uniform resource identifier of the physical artifact. May be empty if there is no physical artifact. - Uri *string `json:"uri,omitempty"` - State *ArtifactState `json:"state,omitempty"` - ArtifactType string `json:"artifactType"` + Uri *string `json:"uri,omitempty"` + State *ArtifactState `json:"state,omitempty"` // Name of the model format. ModelFormatName *string `json:"modelFormatName,omitempty"` // Storage secret name. @@ -49,7 +49,6 @@ func NewModelArtifactUpdate(artifactType string) *ModelArtifactUpdate { this := ModelArtifactUpdate{} var state ArtifactState = ARTIFACTSTATE_UNKNOWN this.State = &state - this.ArtifactType = artifactType return &this } @@ -58,13 +57,37 @@ func NewModelArtifactUpdate(artifactType string) *ModelArtifactUpdate { // but it doesn't guarantee that properties required by API are set func NewModelArtifactUpdateWithDefaults() *ModelArtifactUpdate { this := ModelArtifactUpdate{} - var state ArtifactState = ARTIFACTSTATE_UNKNOWN - this.State = &state var artifactType string = "model-artifact" this.ArtifactType = artifactType + var state ArtifactState = ARTIFACTSTATE_UNKNOWN + this.State = &state return &this } +// GetArtifactType returns the ArtifactType field value +func (o *ModelArtifactUpdate) GetArtifactType() string { + if o == nil { + var ret string + return ret + } + + return o.ArtifactType +} + +// GetArtifactTypeOk returns a tuple with the ArtifactType field value +// and a boolean to check if the value has been set. +func (o *ModelArtifactUpdate) GetArtifactTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ArtifactType, true +} + +// SetArtifactType sets field value +func (o *ModelArtifactUpdate) SetArtifactType(v string) { + o.ArtifactType = v +} + // GetCustomProperties returns the CustomProperties field value if set, zero value otherwise. func (o *ModelArtifactUpdate) GetCustomProperties() map[string]MetadataValue { if o == nil || IsNil(o.CustomProperties) { @@ -225,30 +248,6 @@ func (o *ModelArtifactUpdate) SetState(v ArtifactState) { o.State = &v } -// GetArtifactType returns the ArtifactType field value -func (o *ModelArtifactUpdate) GetArtifactType() string { - if o == nil { - var ret string - return ret - } - - return o.ArtifactType -} - -// GetArtifactTypeOk returns a tuple with the ArtifactType field value -// and a boolean to check if the value has been set. -func (o *ModelArtifactUpdate) GetArtifactTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ArtifactType, true -} - -// SetArtifactType sets field value -func (o *ModelArtifactUpdate) SetArtifactType(v string) { - o.ArtifactType = v -} - // GetModelFormatName returns the ModelFormatName field value if set, zero value otherwise. func (o *ModelArtifactUpdate) GetModelFormatName() string { if o == nil || IsNil(o.ModelFormatName) { @@ -419,6 +418,7 @@ func (o ModelArtifactUpdate) MarshalJSON() ([]byte, error) { func (o ModelArtifactUpdate) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} + toSerialize["artifactType"] = o.ArtifactType if !IsNil(o.CustomProperties) { toSerialize["customProperties"] = o.CustomProperties } @@ -434,7 +434,6 @@ func (o ModelArtifactUpdate) ToMap() (map[string]interface{}, error) { if !IsNil(o.State) { toSerialize["state"] = o.State } - toSerialize["artifactType"] = o.ArtifactType if !IsNil(o.ModelFormatName) { toSerialize["modelFormatName"] = o.ModelFormatName } From 1567e6d06303409c18687ed2546bb166fd2beafc Mon Sep 17 00:00:00 2001 From: Isabella do Amaral Date: Mon, 23 Sep 2024 10:36:32 -0300 Subject: [PATCH 3/3] update existing artifact with custom helper Signed-off-by: Isabella do Amaral --- .../generated/openapi_reconciler.gen.go | 150 ------------------ internal/converter/openapi_reconciler.go | 5 - internal/converter/openapi_reconciler_util.go | 23 +++ .../api_model_registry_service_service.go | 2 +- 4 files changed, 24 insertions(+), 156 deletions(-) create mode 100644 internal/converter/openapi_reconciler_util.go diff --git a/internal/converter/generated/openapi_reconciler.gen.go b/internal/converter/generated/openapi_reconciler.gen.go index cdb8d75a..fcfccce9 100644 --- a/internal/converter/generated/openapi_reconciler.gen.go +++ b/internal/converter/generated/openapi_reconciler.gen.go @@ -11,28 +11,6 @@ import ( type OpenAPIReconcilerImpl struct{} -func (c *OpenAPIReconcilerImpl) UpdateExistingArtifact(source converter.OpenapiUpdateWrapper[openapi.Artifact]) (openapi.Artifact, error) { - openapiArtifact := converter.InitWithExisting(source) - var pOpenapiDocArtifact *openapi.DocArtifact - if source.Update != nil { - pOpenapiDocArtifact = source.Update.DocArtifact - } - pOpenapiDocArtifact2, err := c.pOpenapiDocArtifactToPOpenapiDocArtifact(pOpenapiDocArtifact) - if err != nil { - return openapiArtifact, fmt.Errorf("error setting field DocArtifact: %w", err) - } - openapiArtifact.DocArtifact = pOpenapiDocArtifact2 - var pOpenapiModelArtifact *openapi.ModelArtifact - if source.Update != nil { - pOpenapiModelArtifact = source.Update.ModelArtifact - } - pOpenapiModelArtifact2, err := c.pOpenapiModelArtifactToPOpenapiModelArtifact(pOpenapiModelArtifact) - if err != nil { - return openapiArtifact, fmt.Errorf("error setting field ModelArtifact: %w", err) - } - openapiArtifact.ModelArtifact = pOpenapiModelArtifact2 - return openapiArtifact, nil -} func (c *OpenAPIReconcilerImpl) UpdateExistingDocArtifact(source converter.OpenapiUpdateWrapper[openapi.DocArtifact]) (openapi.DocArtifact, error) { openapiDocArtifact := converter.InitWithExisting(source) var pMapStringOpenapiMetadataValue *map[string]openapi.MetadataValue @@ -515,60 +493,6 @@ func (c *OpenAPIReconcilerImpl) openapiRegisteredModelStateToOpenapiRegisteredMo } return openapiRegisteredModelState, nil } -func (c *OpenAPIReconcilerImpl) pOpenapiDocArtifactToPOpenapiDocArtifact(source *openapi.DocArtifact) (*openapi.DocArtifact, error) { - var pOpenapiDocArtifact *openapi.DocArtifact - if source != nil { - var openapiDocArtifact openapi.DocArtifact - openapiDocArtifact.ArtifactType = (*source).ArtifactType - if (*source).CustomProperties != nil { - var mapStringOpenapiMetadataValue map[string]openapi.MetadataValue - if (*(*source).CustomProperties) != nil { - mapStringOpenapiMetadataValue = make(map[string]openapi.MetadataValue, len((*(*source).CustomProperties))) - for key, value := range *(*source).CustomProperties { - mapStringOpenapiMetadataValue[key] = c.openapiMetadataValueToOpenapiMetadataValue(value) - } - } - openapiDocArtifact.CustomProperties = &mapStringOpenapiMetadataValue - } - if (*source).Description != nil { - xstring := *(*source).Description - openapiDocArtifact.Description = &xstring - } - if (*source).ExternalId != nil { - xstring2 := *(*source).ExternalId - openapiDocArtifact.ExternalId = &xstring2 - } - if (*source).Uri != nil { - xstring3 := *(*source).Uri - openapiDocArtifact.Uri = &xstring3 - } - if (*source).State != nil { - openapiArtifactState, err := c.openapiArtifactStateToOpenapiArtifactState(*(*source).State) - if err != nil { - return nil, fmt.Errorf("error setting field State: %w", err) - } - openapiDocArtifact.State = &openapiArtifactState - } - if (*source).Name != nil { - xstring4 := *(*source).Name - openapiDocArtifact.Name = &xstring4 - } - if (*source).Id != nil { - xstring5 := *(*source).Id - openapiDocArtifact.Id = &xstring5 - } - if (*source).CreateTimeSinceEpoch != nil { - xstring6 := *(*source).CreateTimeSinceEpoch - openapiDocArtifact.CreateTimeSinceEpoch = &xstring6 - } - if (*source).LastUpdateTimeSinceEpoch != nil { - xstring7 := *(*source).LastUpdateTimeSinceEpoch - openapiDocArtifact.LastUpdateTimeSinceEpoch = &xstring7 - } - pOpenapiDocArtifact = &openapiDocArtifact - } - return pOpenapiDocArtifact, nil -} func (c *OpenAPIReconcilerImpl) pOpenapiMetadataBoolValueToPOpenapiMetadataBoolValue(source *openapi.MetadataBoolValue) *openapi.MetadataBoolValue { var pOpenapiMetadataBoolValue *openapi.MetadataBoolValue if source != nil { @@ -630,77 +554,3 @@ func (c *OpenAPIReconcilerImpl) pOpenapiMetadataStructValueToPOpenapiMetadataStr } return pOpenapiMetadataStructValue } -func (c *OpenAPIReconcilerImpl) pOpenapiModelArtifactToPOpenapiModelArtifact(source *openapi.ModelArtifact) (*openapi.ModelArtifact, error) { - var pOpenapiModelArtifact *openapi.ModelArtifact - if source != nil { - var openapiModelArtifact openapi.ModelArtifact - openapiModelArtifact.ArtifactType = (*source).ArtifactType - if (*source).CustomProperties != nil { - var mapStringOpenapiMetadataValue map[string]openapi.MetadataValue - if (*(*source).CustomProperties) != nil { - mapStringOpenapiMetadataValue = make(map[string]openapi.MetadataValue, len((*(*source).CustomProperties))) - for key, value := range *(*source).CustomProperties { - mapStringOpenapiMetadataValue[key] = c.openapiMetadataValueToOpenapiMetadataValue(value) - } - } - openapiModelArtifact.CustomProperties = &mapStringOpenapiMetadataValue - } - if (*source).Description != nil { - xstring := *(*source).Description - openapiModelArtifact.Description = &xstring - } - if (*source).ExternalId != nil { - xstring2 := *(*source).ExternalId - openapiModelArtifact.ExternalId = &xstring2 - } - if (*source).Uri != nil { - xstring3 := *(*source).Uri - openapiModelArtifact.Uri = &xstring3 - } - if (*source).State != nil { - openapiArtifactState, err := c.openapiArtifactStateToOpenapiArtifactState(*(*source).State) - if err != nil { - return nil, fmt.Errorf("error setting field State: %w", err) - } - openapiModelArtifact.State = &openapiArtifactState - } - if (*source).Name != nil { - xstring4 := *(*source).Name - openapiModelArtifact.Name = &xstring4 - } - if (*source).Id != nil { - xstring5 := *(*source).Id - openapiModelArtifact.Id = &xstring5 - } - if (*source).CreateTimeSinceEpoch != nil { - xstring6 := *(*source).CreateTimeSinceEpoch - openapiModelArtifact.CreateTimeSinceEpoch = &xstring6 - } - if (*source).LastUpdateTimeSinceEpoch != nil { - xstring7 := *(*source).LastUpdateTimeSinceEpoch - openapiModelArtifact.LastUpdateTimeSinceEpoch = &xstring7 - } - if (*source).ModelFormatName != nil { - xstring8 := *(*source).ModelFormatName - openapiModelArtifact.ModelFormatName = &xstring8 - } - if (*source).StorageKey != nil { - xstring9 := *(*source).StorageKey - openapiModelArtifact.StorageKey = &xstring9 - } - if (*source).StoragePath != nil { - xstring10 := *(*source).StoragePath - openapiModelArtifact.StoragePath = &xstring10 - } - if (*source).ModelFormatVersion != nil { - xstring11 := *(*source).ModelFormatVersion - openapiModelArtifact.ModelFormatVersion = &xstring11 - } - if (*source).ServiceAccountName != nil { - xstring12 := *(*source).ServiceAccountName - openapiModelArtifact.ServiceAccountName = &xstring12 - } - pOpenapiModelArtifact = &openapiModelArtifact - } - return pOpenapiModelArtifact, nil -} diff --git a/internal/converter/openapi_reconciler.go b/internal/converter/openapi_reconciler.go index d6717015..47cd3395 100644 --- a/internal/converter/openapi_reconciler.go +++ b/internal/converter/openapi_reconciler.go @@ -24,11 +24,6 @@ type OpenAPIReconciler interface { // goverter:ignore Id CreateTimeSinceEpoch LastUpdateTimeSinceEpoch Name RegisteredModelId UpdateExistingModelVersion(source OpenapiUpdateWrapper[openapi.ModelVersion]) (openapi.ModelVersion, error) - // Ignore all fields that can't be updated - // goverter:default InitWithExisting - // goverter:autoMap Update - UpdateExistingArtifact(source OpenapiUpdateWrapper[openapi.Artifact]) (openapi.Artifact, error) - // Ignore all fields that can't be updated // goverter:default InitWithExisting // goverter:autoMap Update diff --git a/internal/converter/openapi_reconciler_util.go b/internal/converter/openapi_reconciler_util.go new file mode 100644 index 00000000..e2b8544c --- /dev/null +++ b/internal/converter/openapi_reconciler_util.go @@ -0,0 +1,23 @@ +package converter + +import ( + "github.com/kubeflow/model-registry/pkg/openapi" +) + +func UpdateExistingArtifact(genc OpenAPIReconciler, source OpenapiUpdateWrapper[openapi.Artifact]) (openapi.Artifact, error) { + art := InitWithExisting(source) + if source.Update == nil { + return art, nil + } + ma, err := genc.UpdateExistingModelArtifact(OpenapiUpdateWrapper[openapi.ModelArtifact]{Existing: art.ModelArtifact, Update: source.Update.ModelArtifact}) + if err != nil { + return art, err + } + da, err := genc.UpdateExistingDocArtifact(OpenapiUpdateWrapper[openapi.DocArtifact]{Existing: art.DocArtifact, Update: source.Update.DocArtifact}) + if err != nil { + return art, err + } + art.DocArtifact = &da + art.ModelArtifact = &ma + return art, nil +} diff --git a/internal/server/openapi/api_model_registry_service_service.go b/internal/server/openapi/api_model_registry_service_service.go index cc4c239b..d22b38c2 100644 --- a/internal/server/openapi/api_model_registry_service_service.go +++ b/internal/server/openapi/api_model_registry_service_service.go @@ -499,7 +499,7 @@ func (s *ModelRegistryServiceAPIService) UpdateArtifact(ctx context.Context, art if err != nil { return ErrorResponse(api.ErrToStatus(err), err), err } - update, err := s.reconciler.UpdateExistingArtifact(converter.NewOpenapiUpdateWrapper(existing, entity)) + update, err := converter.UpdateExistingArtifact(s.reconciler, converter.NewOpenapiUpdateWrapper(existing, entity)) if err != nil { return ErrorResponse(http.StatusBadRequest, err), err }