databricks-cli/cmd/workspace/model-registry/model-registry.go

1245 lines
34 KiB
Go
Raw Normal View History

Added OpenAPI command coverage (#357) This PR adds the following command groups: ## Workspace-level command groups * `bricks alerts` - The alerts API can be used to perform CRUD operations on alerts. * `bricks catalogs` - A catalog is the first layer of Unity Catalog’s three-level namespace. * `bricks cluster-policies` - Cluster policy limits the ability to configure clusters based on a set of rules. * `bricks clusters` - The Clusters API allows you to create, start, edit, list, terminate, and delete clusters. * `bricks current-user` - This API allows retrieving information about currently authenticated user or service principal. * `bricks dashboards` - In general, there is little need to modify dashboards using the API. * `bricks data-sources` - This API is provided to assist you in making new query objects. * `bricks experiments` - MLflow Experiment tracking. * `bricks external-locations` - An external location is an object that combines a cloud storage path with a storage credential that authorizes access to the cloud storage path. * `bricks functions` - Functions implement User-Defined Functions (UDFs) in Unity Catalog. * `bricks git-credentials` - Registers personal access token for Databricks to do operations on behalf of the user. * `bricks global-init-scripts` - The Global Init Scripts API enables Workspace administrators to configure global initialization scripts for their workspace. * `bricks grants` - In Unity Catalog, data is secure by default. * `bricks groups` - Groups simplify identity management, making it easier to assign access to Databricks Workspace, data, and other securable objects. * `bricks instance-pools` - Instance Pools API are used to create, edit, delete and list instance pools by using ready-to-use cloud instances which reduces a cluster start and auto-scaling times. * `bricks instance-profiles` - The Instance Profiles API allows admins to add, list, and remove instance profiles that users can launch clusters with. * `bricks ip-access-lists` - IP Access List enables admins to configure IP access lists. * `bricks jobs` - The Jobs API allows you to create, edit, and delete jobs. * `bricks libraries` - The Libraries API allows you to install and uninstall libraries and get the status of libraries on a cluster. * `bricks metastores` - A metastore is the top-level container of objects in Unity Catalog. * `bricks model-registry` - MLflow Model Registry commands. * `bricks permissions` - Permissions API are used to create read, write, edit, update and manage access for various users on different objects and endpoints. * `bricks pipelines` - The Delta Live Tables API allows you to create, edit, delete, start, and view details about pipelines. * `bricks policy-families` - View available policy families. * `bricks providers` - Databricks Providers REST API. * `bricks queries` - These endpoints are used for CRUD operations on query definitions. * `bricks query-history` - Access the history of queries through SQL warehouses. * `bricks recipient-activation` - Databricks Recipient Activation REST API. * `bricks recipients` - Databricks Recipients REST API. * `bricks repos` - The Repos API allows users to manage their git repos. * `bricks schemas` - A schema (also called a database) is the second layer of Unity Catalog’s three-level namespace. * `bricks secrets` - The Secrets API allows you to manage secrets, secret scopes, and access permissions. * `bricks service-principals` - Identities for use with jobs, automated tools, and systems such as scripts, apps, and CI/CD platforms. * `bricks serving-endpoints` - The Serving Endpoints API allows you to create, update, and delete model serving endpoints. * `bricks shares` - Databricks Shares REST API. * `bricks storage-credentials` - A storage credential represents an authentication and authorization mechanism for accessing data stored on your cloud tenant. * `bricks table-constraints` - Primary key and foreign key constraints encode relationships between fields in tables. * `bricks tables` - A table resides in the third layer of Unity Catalog’s three-level namespace. * `bricks token-management` - Enables administrators to get all tokens and delete tokens for other users. * `bricks tokens` - The Token API allows you to create, list, and revoke tokens that can be used to authenticate and access Databricks REST APIs. * `bricks users` - User identities recognized by Databricks and represented by email addresses. * `bricks volumes` - Volumes are a Unity Catalog (UC) capability for accessing, storing, governing, organizing and processing files. * `bricks warehouses` - A SQL warehouse is a compute resource that lets you run SQL commands on data objects within Databricks SQL. * `bricks workspace` - The Workspace API allows you to list, import, export, and delete notebooks and folders. * `bricks workspace-conf` - This API allows updating known workspace settings for advanced users. ## Account-level command groups * `bricks account billable-usage` - This API allows you to download billable usage logs for the specified account and date range. * `bricks account budgets` - These APIs manage budget configuration including notifications for exceeding a budget for a period. * `bricks account credentials` - These APIs manage credential configurations for this workspace. * `bricks account custom-app-integration` - These APIs enable administrators to manage custom oauth app integrations, which is required for adding/using Custom OAuth App Integration like Tableau Cloud for Databricks in AWS cloud. * `bricks account encryption-keys` - These APIs manage encryption key configurations for this workspace (optional). * `bricks account groups` - Groups simplify identity management, making it easier to assign access to Databricks Account, data, and other securable objects. * `bricks account ip-access-lists` - The Accounts IP Access List API enables account admins to configure IP access lists for access to the account console. * `bricks account log-delivery` - These APIs manage log delivery configurations for this account. * `bricks account metastore-assignments` - These APIs manage metastore assignments to a workspace. * `bricks account metastores` - These APIs manage Unity Catalog metastores for an account. * `bricks account networks` - These APIs manage network configurations for customer-managed VPCs (optional). * `bricks account o-auth-enrollment` - These APIs enable administrators to enroll OAuth for their accounts, which is required for adding/using any OAuth published/custom application integration. * `bricks account private-access` - These APIs manage private access settings for this account. * `bricks account published-app-integration` - These APIs enable administrators to manage published oauth app integrations, which is required for adding/using Published OAuth App Integration like Tableau Cloud for Databricks in AWS cloud. * `bricks account service-principals` - Identities for use with jobs, automated tools, and systems such as scripts, apps, and CI/CD platforms. * `bricks account storage` - These APIs manage storage configurations for this workspace. * `bricks account storage-credentials` - These APIs manage storage credentials for a particular metastore. * `bricks account users` - User identities recognized by Databricks and represented by email addresses. * `bricks account vpc-endpoints` - These APIs manage VPC endpoint configurations for this account. * `bricks account workspace-assignment` - The Workspace Permission Assignment API allows you to manage workspace permissions for principals in your account. * `bricks account workspaces` - These APIs manage workspaces for this account.
2023-04-26 11:06:16 +00:00
// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
package model_registry
import (
"fmt"
"github.com/databricks/cli/cmd/root"
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/flags"
Added OpenAPI command coverage (#357) This PR adds the following command groups: ## Workspace-level command groups * `bricks alerts` - The alerts API can be used to perform CRUD operations on alerts. * `bricks catalogs` - A catalog is the first layer of Unity Catalog’s three-level namespace. * `bricks cluster-policies` - Cluster policy limits the ability to configure clusters based on a set of rules. * `bricks clusters` - The Clusters API allows you to create, start, edit, list, terminate, and delete clusters. * `bricks current-user` - This API allows retrieving information about currently authenticated user or service principal. * `bricks dashboards` - In general, there is little need to modify dashboards using the API. * `bricks data-sources` - This API is provided to assist you in making new query objects. * `bricks experiments` - MLflow Experiment tracking. * `bricks external-locations` - An external location is an object that combines a cloud storage path with a storage credential that authorizes access to the cloud storage path. * `bricks functions` - Functions implement User-Defined Functions (UDFs) in Unity Catalog. * `bricks git-credentials` - Registers personal access token for Databricks to do operations on behalf of the user. * `bricks global-init-scripts` - The Global Init Scripts API enables Workspace administrators to configure global initialization scripts for their workspace. * `bricks grants` - In Unity Catalog, data is secure by default. * `bricks groups` - Groups simplify identity management, making it easier to assign access to Databricks Workspace, data, and other securable objects. * `bricks instance-pools` - Instance Pools API are used to create, edit, delete and list instance pools by using ready-to-use cloud instances which reduces a cluster start and auto-scaling times. * `bricks instance-profiles` - The Instance Profiles API allows admins to add, list, and remove instance profiles that users can launch clusters with. * `bricks ip-access-lists` - IP Access List enables admins to configure IP access lists. * `bricks jobs` - The Jobs API allows you to create, edit, and delete jobs. * `bricks libraries` - The Libraries API allows you to install and uninstall libraries and get the status of libraries on a cluster. * `bricks metastores` - A metastore is the top-level container of objects in Unity Catalog. * `bricks model-registry` - MLflow Model Registry commands. * `bricks permissions` - Permissions API are used to create read, write, edit, update and manage access for various users on different objects and endpoints. * `bricks pipelines` - The Delta Live Tables API allows you to create, edit, delete, start, and view details about pipelines. * `bricks policy-families` - View available policy families. * `bricks providers` - Databricks Providers REST API. * `bricks queries` - These endpoints are used for CRUD operations on query definitions. * `bricks query-history` - Access the history of queries through SQL warehouses. * `bricks recipient-activation` - Databricks Recipient Activation REST API. * `bricks recipients` - Databricks Recipients REST API. * `bricks repos` - The Repos API allows users to manage their git repos. * `bricks schemas` - A schema (also called a database) is the second layer of Unity Catalog’s three-level namespace. * `bricks secrets` - The Secrets API allows you to manage secrets, secret scopes, and access permissions. * `bricks service-principals` - Identities for use with jobs, automated tools, and systems such as scripts, apps, and CI/CD platforms. * `bricks serving-endpoints` - The Serving Endpoints API allows you to create, update, and delete model serving endpoints. * `bricks shares` - Databricks Shares REST API. * `bricks storage-credentials` - A storage credential represents an authentication and authorization mechanism for accessing data stored on your cloud tenant. * `bricks table-constraints` - Primary key and foreign key constraints encode relationships between fields in tables. * `bricks tables` - A table resides in the third layer of Unity Catalog’s three-level namespace. * `bricks token-management` - Enables administrators to get all tokens and delete tokens for other users. * `bricks tokens` - The Token API allows you to create, list, and revoke tokens that can be used to authenticate and access Databricks REST APIs. * `bricks users` - User identities recognized by Databricks and represented by email addresses. * `bricks volumes` - Volumes are a Unity Catalog (UC) capability for accessing, storing, governing, organizing and processing files. * `bricks warehouses` - A SQL warehouse is a compute resource that lets you run SQL commands on data objects within Databricks SQL. * `bricks workspace` - The Workspace API allows you to list, import, export, and delete notebooks and folders. * `bricks workspace-conf` - This API allows updating known workspace settings for advanced users. ## Account-level command groups * `bricks account billable-usage` - This API allows you to download billable usage logs for the specified account and date range. * `bricks account budgets` - These APIs manage budget configuration including notifications for exceeding a budget for a period. * `bricks account credentials` - These APIs manage credential configurations for this workspace. * `bricks account custom-app-integration` - These APIs enable administrators to manage custom oauth app integrations, which is required for adding/using Custom OAuth App Integration like Tableau Cloud for Databricks in AWS cloud. * `bricks account encryption-keys` - These APIs manage encryption key configurations for this workspace (optional). * `bricks account groups` - Groups simplify identity management, making it easier to assign access to Databricks Account, data, and other securable objects. * `bricks account ip-access-lists` - The Accounts IP Access List API enables account admins to configure IP access lists for access to the account console. * `bricks account log-delivery` - These APIs manage log delivery configurations for this account. * `bricks account metastore-assignments` - These APIs manage metastore assignments to a workspace. * `bricks account metastores` - These APIs manage Unity Catalog metastores for an account. * `bricks account networks` - These APIs manage network configurations for customer-managed VPCs (optional). * `bricks account o-auth-enrollment` - These APIs enable administrators to enroll OAuth for their accounts, which is required for adding/using any OAuth published/custom application integration. * `bricks account private-access` - These APIs manage private access settings for this account. * `bricks account published-app-integration` - These APIs enable administrators to manage published oauth app integrations, which is required for adding/using Published OAuth App Integration like Tableau Cloud for Databricks in AWS cloud. * `bricks account service-principals` - Identities for use with jobs, automated tools, and systems such as scripts, apps, and CI/CD platforms. * `bricks account storage` - These APIs manage storage configurations for this workspace. * `bricks account storage-credentials` - These APIs manage storage credentials for a particular metastore. * `bricks account users` - User identities recognized by Databricks and represented by email addresses. * `bricks account vpc-endpoints` - These APIs manage VPC endpoint configurations for this account. * `bricks account workspace-assignment` - The Workspace Permission Assignment API allows you to manage workspace permissions for principals in your account. * `bricks account workspaces` - These APIs manage workspaces for this account.
2023-04-26 11:06:16 +00:00
"github.com/databricks/databricks-sdk-go/service/ml"
"github.com/spf13/cobra"
)
var Cmd = &cobra.Command{
Use: "model-registry",
}
// start approve-transition-request command
var approveTransitionRequestReq ml.ApproveTransitionRequest
func init() {
Cmd.AddCommand(approveTransitionRequestCmd)
// TODO: short flags
approveTransitionRequestCmd.Flags().StringVar(&approveTransitionRequestReq.Comment, "comment", approveTransitionRequestReq.Comment, `User-provided comment on the action.`)
}
var approveTransitionRequestCmd = &cobra.Command{
Use: "approve-transition-request NAME VERSION STAGE ARCHIVE_EXISTING_VERSIONS",
Short: `Approve transition request.`,
Long: `Approve transition request.
Approves a model version stage transition request.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(4),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
approveTransitionRequestReq.Name = args[0]
approveTransitionRequestReq.Version = args[1]
_, err = fmt.Sscan(args[2], &approveTransitionRequestReq.Stage)
if err != nil {
return fmt.Errorf("invalid STAGE: %s", args[2])
}
_, err = fmt.Sscan(args[3], &approveTransitionRequestReq.ArchiveExistingVersions)
if err != nil {
return fmt.Errorf("invalid ARCHIVE_EXISTING_VERSIONS: %s", args[3])
}
response, err := w.ModelRegistry.ApproveTransitionRequest(ctx, approveTransitionRequestReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
},
}
// start create-comment command
var createCommentReq ml.CreateComment
func init() {
Cmd.AddCommand(createCommentCmd)
// TODO: short flags
}
var createCommentCmd = &cobra.Command{
Use: "create-comment NAME VERSION COMMENT",
Short: `Post a comment.`,
Long: `Post a comment.
Posts a comment on a model version. A comment can be submitted either by a
user or programmatically to display relevant information about the model. For
example, test results or deployment errors.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(3),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
createCommentReq.Name = args[0]
createCommentReq.Version = args[1]
createCommentReq.Comment = args[2]
response, err := w.ModelRegistry.CreateComment(ctx, createCommentReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
},
}
// start create-model command
var createModelReq ml.CreateModelRequest
var createModelJson flags.JsonFlag
func init() {
Cmd.AddCommand(createModelCmd)
// TODO: short flags
createModelCmd.Flags().Var(&createModelJson, "json", `either inline JSON string or @path/to/file.json with request body`)
createModelCmd.Flags().StringVar(&createModelReq.Description, "description", createModelReq.Description, `Optional description for registered model.`)
// TODO: array: tags
}
var createModelCmd = &cobra.Command{
Use: "create-model",
Short: `Create a model.`,
Long: `Create a model.
Creates a new registered model with the name specified in the request body.
Throws RESOURCE_ALREADY_EXISTS if a registered model with the given name
exists.`,
Annotations: map[string]string{},
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
err = createModelJson.Unmarshal(&createModelReq)
if err != nil {
return err
}
createModelReq.Name = args[0]
response, err := w.ModelRegistry.CreateModel(ctx, createModelReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
},
}
// start create-model-version command
var createModelVersionReq ml.CreateModelVersionRequest
var createModelVersionJson flags.JsonFlag
func init() {
Cmd.AddCommand(createModelVersionCmd)
// TODO: short flags
createModelVersionCmd.Flags().Var(&createModelVersionJson, "json", `either inline JSON string or @path/to/file.json with request body`)
createModelVersionCmd.Flags().StringVar(&createModelVersionReq.Description, "description", createModelVersionReq.Description, `Optional description for model version.`)
createModelVersionCmd.Flags().StringVar(&createModelVersionReq.RunId, "run-id", createModelVersionReq.RunId, `MLflow run ID for correlation, if source was generated by an experiment run in MLflow tracking server.`)
createModelVersionCmd.Flags().StringVar(&createModelVersionReq.RunLink, "run-link", createModelVersionReq.RunLink, `MLflow run link - this is the exact link of the run that generated this model version, potentially hosted at another instance of MLflow.`)
// TODO: array: tags
}
var createModelVersionCmd = &cobra.Command{
Use: "create-model-version",
Short: `Create a model version.`,
Long: `Create a model version.
Creates a model version.`,
Annotations: map[string]string{},
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
err = createModelVersionJson.Unmarshal(&createModelVersionReq)
if err != nil {
return err
}
createModelVersionReq.Name = args[0]
createModelVersionReq.Source = args[1]
response, err := w.ModelRegistry.CreateModelVersion(ctx, createModelVersionReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
},
}
// start create-transition-request command
var createTransitionRequestReq ml.CreateTransitionRequest
func init() {
Cmd.AddCommand(createTransitionRequestCmd)
// TODO: short flags
createTransitionRequestCmd.Flags().StringVar(&createTransitionRequestReq.Comment, "comment", createTransitionRequestReq.Comment, `User-provided comment on the action.`)
}
var createTransitionRequestCmd = &cobra.Command{
Use: "create-transition-request NAME VERSION STAGE",
Short: `Make a transition request.`,
Long: `Make a transition request.
Creates a model version stage transition request.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(3),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
createTransitionRequestReq.Name = args[0]
createTransitionRequestReq.Version = args[1]
_, err = fmt.Sscan(args[2], &createTransitionRequestReq.Stage)
if err != nil {
return fmt.Errorf("invalid STAGE: %s", args[2])
}
response, err := w.ModelRegistry.CreateTransitionRequest(ctx, createTransitionRequestReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
},
}
// start create-webhook command
var createWebhookReq ml.CreateRegistryWebhook
var createWebhookJson flags.JsonFlag
func init() {
Cmd.AddCommand(createWebhookCmd)
// TODO: short flags
createWebhookCmd.Flags().Var(&createWebhookJson, "json", `either inline JSON string or @path/to/file.json with request body`)
createWebhookCmd.Flags().StringVar(&createWebhookReq.Description, "description", createWebhookReq.Description, `User-specified description for the webhook.`)
// TODO: complex arg: http_url_spec
// TODO: complex arg: job_spec
createWebhookCmd.Flags().StringVar(&createWebhookReq.ModelName, "model-name", createWebhookReq.ModelName, `Name of the model whose events would trigger this webhook.`)
createWebhookCmd.Flags().Var(&createWebhookReq.Status, "status", `This describes an enum.`)
}
var createWebhookCmd = &cobra.Command{
Use: "create-webhook",
Short: `Create a webhook.`,
Long: `Create a webhook.
**NOTE**: This endpoint is in Public Preview.
Creates a registry webhook.`,
Annotations: map[string]string{},
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
err = createWebhookJson.Unmarshal(&createWebhookReq)
if err != nil {
return err
}
_, err = fmt.Sscan(args[0], &createWebhookReq.Events)
if err != nil {
return fmt.Errorf("invalid EVENTS: %s", args[0])
}
response, err := w.ModelRegistry.CreateWebhook(ctx, createWebhookReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
},
}
// start delete-comment command
var deleteCommentReq ml.DeleteCommentRequest
func init() {
Cmd.AddCommand(deleteCommentCmd)
// TODO: short flags
}
var deleteCommentCmd = &cobra.Command{
Use: "delete-comment ID",
Short: `Delete a comment.`,
Long: `Delete a comment.
Deletes a comment on a model version.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(1),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
deleteCommentReq.Id = args[0]
err = w.ModelRegistry.DeleteComment(ctx, deleteCommentReq)
if err != nil {
return err
}
return nil
},
}
// start delete-model command
var deleteModelReq ml.DeleteModelRequest
func init() {
Cmd.AddCommand(deleteModelCmd)
// TODO: short flags
}
var deleteModelCmd = &cobra.Command{
Use: "delete-model NAME",
Short: `Delete a model.`,
Long: `Delete a model.
Deletes a registered model.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(1),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
deleteModelReq.Name = args[0]
err = w.ModelRegistry.DeleteModel(ctx, deleteModelReq)
if err != nil {
return err
}
return nil
},
}
// start delete-model-tag command
var deleteModelTagReq ml.DeleteModelTagRequest
func init() {
Cmd.AddCommand(deleteModelTagCmd)
// TODO: short flags
}
var deleteModelTagCmd = &cobra.Command{
Use: "delete-model-tag NAME KEY",
Short: `Delete a model tag.`,
Long: `Delete a model tag.
Deletes the tag for a registered model.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(2),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
deleteModelTagReq.Name = args[0]
deleteModelTagReq.Key = args[1]
err = w.ModelRegistry.DeleteModelTag(ctx, deleteModelTagReq)
if err != nil {
return err
}
return nil
},
}
// start delete-model-version command
var deleteModelVersionReq ml.DeleteModelVersionRequest
func init() {
Cmd.AddCommand(deleteModelVersionCmd)
// TODO: short flags
}
var deleteModelVersionCmd = &cobra.Command{
Use: "delete-model-version NAME VERSION",
Short: `Delete a model version.`,
Long: `Delete a model version.
Deletes a model version.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(2),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
deleteModelVersionReq.Name = args[0]
deleteModelVersionReq.Version = args[1]
err = w.ModelRegistry.DeleteModelVersion(ctx, deleteModelVersionReq)
if err != nil {
return err
}
return nil
},
}
// start delete-model-version-tag command
var deleteModelVersionTagReq ml.DeleteModelVersionTagRequest
func init() {
Cmd.AddCommand(deleteModelVersionTagCmd)
// TODO: short flags
}
var deleteModelVersionTagCmd = &cobra.Command{
Use: "delete-model-version-tag NAME VERSION KEY",
Short: `Delete a model version tag.`,
Long: `Delete a model version tag.
Deletes a model version tag.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(3),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
deleteModelVersionTagReq.Name = args[0]
deleteModelVersionTagReq.Version = args[1]
deleteModelVersionTagReq.Key = args[2]
err = w.ModelRegistry.DeleteModelVersionTag(ctx, deleteModelVersionTagReq)
if err != nil {
return err
}
return nil
},
}
// start delete-transition-request command
var deleteTransitionRequestReq ml.DeleteTransitionRequestRequest
func init() {
Cmd.AddCommand(deleteTransitionRequestCmd)
// TODO: short flags
deleteTransitionRequestCmd.Flags().StringVar(&deleteTransitionRequestReq.Comment, "comment", deleteTransitionRequestReq.Comment, `User-provided comment on the action.`)
}
var deleteTransitionRequestCmd = &cobra.Command{
Use: "delete-transition-request NAME VERSION STAGE CREATOR",
Short: `Delete a ransition request.`,
Long: `Delete a ransition request.
Cancels a model version stage transition request.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(4),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
deleteTransitionRequestReq.Name = args[0]
deleteTransitionRequestReq.Version = args[1]
deleteTransitionRequestReq.Stage = args[2]
deleteTransitionRequestReq.Creator = args[3]
err = w.ModelRegistry.DeleteTransitionRequest(ctx, deleteTransitionRequestReq)
if err != nil {
return err
}
return nil
},
}
// start delete-webhook command
var deleteWebhookReq ml.DeleteWebhookRequest
func init() {
Cmd.AddCommand(deleteWebhookCmd)
// TODO: short flags
deleteWebhookCmd.Flags().StringVar(&deleteWebhookReq.Id, "id", deleteWebhookReq.Id, `Webhook ID required to delete a registry webhook.`)
}
var deleteWebhookCmd = &cobra.Command{
Use: "delete-webhook",
Short: `Delete a webhook.`,
Long: `Delete a webhook.
**NOTE:** This endpoint is in Public Preview.
Deletes a registry webhook.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(0),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
err = w.ModelRegistry.DeleteWebhook(ctx, deleteWebhookReq)
if err != nil {
return err
}
return nil
},
}
// start get-latest-versions command
var getLatestVersionsReq ml.GetLatestVersionsRequest
var getLatestVersionsJson flags.JsonFlag
func init() {
Cmd.AddCommand(getLatestVersionsCmd)
// TODO: short flags
getLatestVersionsCmd.Flags().Var(&getLatestVersionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
// TODO: array: stages
}
var getLatestVersionsCmd = &cobra.Command{
Use: "get-latest-versions",
Short: `Get the latest version.`,
Long: `Get the latest version.
Gets the latest version of a registered model.`,
Annotations: map[string]string{},
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
err = getLatestVersionsJson.Unmarshal(&getLatestVersionsReq)
if err != nil {
return err
}
getLatestVersionsReq.Name = args[0]
response, err := w.ModelRegistry.GetLatestVersionsAll(ctx, getLatestVersionsReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
},
}
// start get-model command
var getModelReq ml.GetModelRequest
func init() {
Cmd.AddCommand(getModelCmd)
// TODO: short flags
}
var getModelCmd = &cobra.Command{
Use: "get-model NAME",
Short: `Get model.`,
Long: `Get model.
Get the details of a model. This is a Databricks Workspace version of the
[MLflow endpoint] that also returns the model's Databricks Workspace ID and
the permission level of the requesting user on the model.
[MLflow endpoint]: https://www.mlflow.org/docs/latest/rest-api.html#get-registeredmodel`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(1),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
getModelReq.Name = args[0]
response, err := w.ModelRegistry.GetModel(ctx, getModelReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
},
}
// start get-model-version command
var getModelVersionReq ml.GetModelVersionRequest
func init() {
Cmd.AddCommand(getModelVersionCmd)
// TODO: short flags
}
var getModelVersionCmd = &cobra.Command{
Use: "get-model-version NAME VERSION",
Short: `Get a model version.`,
Long: `Get a model version.
Get a model version.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(2),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
getModelVersionReq.Name = args[0]
getModelVersionReq.Version = args[1]
response, err := w.ModelRegistry.GetModelVersion(ctx, getModelVersionReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
},
}
// start get-model-version-download-uri command
var getModelVersionDownloadUriReq ml.GetModelVersionDownloadUriRequest
func init() {
Cmd.AddCommand(getModelVersionDownloadUriCmd)
// TODO: short flags
}
var getModelVersionDownloadUriCmd = &cobra.Command{
Use: "get-model-version-download-uri NAME VERSION",
Short: `Get a model version URI.`,
Long: `Get a model version URI.
Gets a URI to download the model version.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(2),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
getModelVersionDownloadUriReq.Name = args[0]
getModelVersionDownloadUriReq.Version = args[1]
response, err := w.ModelRegistry.GetModelVersionDownloadUri(ctx, getModelVersionDownloadUriReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
},
}
// start list-models command
var listModelsReq ml.ListModelsRequest
func init() {
Cmd.AddCommand(listModelsCmd)
// TODO: short flags
listModelsCmd.Flags().IntVar(&listModelsReq.MaxResults, "max-results", listModelsReq.MaxResults, `Maximum number of registered models desired.`)
listModelsCmd.Flags().StringVar(&listModelsReq.PageToken, "page-token", listModelsReq.PageToken, `Pagination token to go to the next page based on a previous query.`)
}
var listModelsCmd = &cobra.Command{
Use: "list-models",
Short: `List models.`,
Long: `List models.
Lists all available registered models, up to the limit specified in
__max_results__.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(0),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
response, err := w.ModelRegistry.ListModelsAll(ctx, listModelsReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
},
}
// start list-transition-requests command
var listTransitionRequestsReq ml.ListTransitionRequestsRequest
func init() {
Cmd.AddCommand(listTransitionRequestsCmd)
// TODO: short flags
}
var listTransitionRequestsCmd = &cobra.Command{
Use: "list-transition-requests NAME VERSION",
Short: `List transition requests.`,
Long: `List transition requests.
Gets a list of all open stage transition requests for the model version.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(2),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
listTransitionRequestsReq.Name = args[0]
listTransitionRequestsReq.Version = args[1]
response, err := w.ModelRegistry.ListTransitionRequestsAll(ctx, listTransitionRequestsReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
},
}
// start list-webhooks command
var listWebhooksReq ml.ListWebhooksRequest
var listWebhooksJson flags.JsonFlag
func init() {
Cmd.AddCommand(listWebhooksCmd)
// TODO: short flags
listWebhooksCmd.Flags().Var(&listWebhooksJson, "json", `either inline JSON string or @path/to/file.json with request body`)
// TODO: array: events
listWebhooksCmd.Flags().StringVar(&listWebhooksReq.ModelName, "model-name", listWebhooksReq.ModelName, `If not specified, all webhooks associated with the specified events are listed, regardless of their associated model.`)
listWebhooksCmd.Flags().StringVar(&listWebhooksReq.PageToken, "page-token", listWebhooksReq.PageToken, `Token indicating the page of artifact results to fetch.`)
}
var listWebhooksCmd = &cobra.Command{
Use: "list-webhooks",
Short: `List registry webhooks.`,
Long: `List registry webhooks.
**NOTE:** This endpoint is in Public Preview.
Lists all registry webhooks.`,
Annotations: map[string]string{},
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
err = listWebhooksJson.Unmarshal(&listWebhooksReq)
if err != nil {
return err
}
response, err := w.ModelRegistry.ListWebhooksAll(ctx, listWebhooksReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
},
}
// start reject-transition-request command
var rejectTransitionRequestReq ml.RejectTransitionRequest
func init() {
Cmd.AddCommand(rejectTransitionRequestCmd)
// TODO: short flags
rejectTransitionRequestCmd.Flags().StringVar(&rejectTransitionRequestReq.Comment, "comment", rejectTransitionRequestReq.Comment, `User-provided comment on the action.`)
}
var rejectTransitionRequestCmd = &cobra.Command{
Use: "reject-transition-request NAME VERSION STAGE",
Short: `Reject a transition request.`,
Long: `Reject a transition request.
Rejects a model version stage transition request.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(3),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
rejectTransitionRequestReq.Name = args[0]
rejectTransitionRequestReq.Version = args[1]
_, err = fmt.Sscan(args[2], &rejectTransitionRequestReq.Stage)
if err != nil {
return fmt.Errorf("invalid STAGE: %s", args[2])
}
response, err := w.ModelRegistry.RejectTransitionRequest(ctx, rejectTransitionRequestReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
},
}
// start rename-model command
var renameModelReq ml.RenameModelRequest
func init() {
Cmd.AddCommand(renameModelCmd)
// TODO: short flags
renameModelCmd.Flags().StringVar(&renameModelReq.NewName, "new-name", renameModelReq.NewName, `If provided, updates the name for this registered_model.`)
}
var renameModelCmd = &cobra.Command{
Use: "rename-model NAME",
Short: `Rename a model.`,
Long: `Rename a model.
Renames a registered model.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(1),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
renameModelReq.Name = args[0]
response, err := w.ModelRegistry.RenameModel(ctx, renameModelReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
},
}
// start search-model-versions command
var searchModelVersionsReq ml.SearchModelVersionsRequest
var searchModelVersionsJson flags.JsonFlag
func init() {
Cmd.AddCommand(searchModelVersionsCmd)
// TODO: short flags
searchModelVersionsCmd.Flags().Var(&searchModelVersionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
searchModelVersionsCmd.Flags().StringVar(&searchModelVersionsReq.Filter, "filter", searchModelVersionsReq.Filter, `String filter condition, like "name='my-model-name'".`)
searchModelVersionsCmd.Flags().IntVar(&searchModelVersionsReq.MaxResults, "max-results", searchModelVersionsReq.MaxResults, `Maximum number of models desired.`)
// TODO: array: order_by
searchModelVersionsCmd.Flags().StringVar(&searchModelVersionsReq.PageToken, "page-token", searchModelVersionsReq.PageToken, `Pagination token to go to next page based on previous search query.`)
}
var searchModelVersionsCmd = &cobra.Command{
Use: "search-model-versions",
Short: `Searches model versions.`,
Long: `Searches model versions.
Searches for specific model versions based on the supplied __filter__.`,
Annotations: map[string]string{},
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
err = searchModelVersionsJson.Unmarshal(&searchModelVersionsReq)
if err != nil {
return err
}
response, err := w.ModelRegistry.SearchModelVersionsAll(ctx, searchModelVersionsReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
},
}
// start search-models command
var searchModelsReq ml.SearchModelsRequest
var searchModelsJson flags.JsonFlag
func init() {
Cmd.AddCommand(searchModelsCmd)
// TODO: short flags
searchModelsCmd.Flags().Var(&searchModelsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
searchModelsCmd.Flags().StringVar(&searchModelsReq.Filter, "filter", searchModelsReq.Filter, `String filter condition, like "name LIKE 'my-model-name'".`)
searchModelsCmd.Flags().IntVar(&searchModelsReq.MaxResults, "max-results", searchModelsReq.MaxResults, `Maximum number of models desired.`)
// TODO: array: order_by
searchModelsCmd.Flags().StringVar(&searchModelsReq.PageToken, "page-token", searchModelsReq.PageToken, `Pagination token to go to the next page based on a previous search query.`)
}
var searchModelsCmd = &cobra.Command{
Use: "search-models",
Short: `Search models.`,
Long: `Search models.
Search for registered models based on the specified __filter__.`,
Annotations: map[string]string{},
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
err = searchModelsJson.Unmarshal(&searchModelsReq)
if err != nil {
return err
}
response, err := w.ModelRegistry.SearchModelsAll(ctx, searchModelsReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
},
}
// start set-model-tag command
var setModelTagReq ml.SetModelTagRequest
func init() {
Cmd.AddCommand(setModelTagCmd)
// TODO: short flags
}
var setModelTagCmd = &cobra.Command{
Use: "set-model-tag NAME KEY VALUE",
Short: `Set a tag.`,
Long: `Set a tag.
Sets a tag on a registered model.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(3),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
setModelTagReq.Name = args[0]
setModelTagReq.Key = args[1]
setModelTagReq.Value = args[2]
err = w.ModelRegistry.SetModelTag(ctx, setModelTagReq)
if err != nil {
return err
}
return nil
},
}
// start set-model-version-tag command
var setModelVersionTagReq ml.SetModelVersionTagRequest
func init() {
Cmd.AddCommand(setModelVersionTagCmd)
// TODO: short flags
}
var setModelVersionTagCmd = &cobra.Command{
Use: "set-model-version-tag NAME VERSION KEY VALUE",
Short: `Set a version tag.`,
Long: `Set a version tag.
Sets a model version tag.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(4),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
setModelVersionTagReq.Name = args[0]
setModelVersionTagReq.Version = args[1]
setModelVersionTagReq.Key = args[2]
setModelVersionTagReq.Value = args[3]
err = w.ModelRegistry.SetModelVersionTag(ctx, setModelVersionTagReq)
if err != nil {
return err
}
return nil
},
}
// start test-registry-webhook command
var testRegistryWebhookReq ml.TestRegistryWebhookRequest
func init() {
Cmd.AddCommand(testRegistryWebhookCmd)
// TODO: short flags
testRegistryWebhookCmd.Flags().Var(&testRegistryWebhookReq.Event, "event", `If event is specified, the test trigger uses the specified event.`)
}
var testRegistryWebhookCmd = &cobra.Command{
Use: "test-registry-webhook ID",
Short: `Test a webhook.`,
Long: `Test a webhook.
**NOTE:** This endpoint is in Public Preview.
Tests a registry webhook.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(1),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
testRegistryWebhookReq.Id = args[0]
response, err := w.ModelRegistry.TestRegistryWebhook(ctx, testRegistryWebhookReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
},
}
// start transition-stage command
var transitionStageReq ml.TransitionModelVersionStageDatabricks
func init() {
Cmd.AddCommand(transitionStageCmd)
// TODO: short flags
transitionStageCmd.Flags().StringVar(&transitionStageReq.Comment, "comment", transitionStageReq.Comment, `User-provided comment on the action.`)
}
var transitionStageCmd = &cobra.Command{
Use: "transition-stage NAME VERSION STAGE ARCHIVE_EXISTING_VERSIONS",
Short: `Transition a stage.`,
Long: `Transition a stage.
Transition a model version's stage. This is a Databricks Workspace version of
the [MLflow endpoint] that also accepts a comment associated with the
transition to be recorded.",
[MLflow endpoint]: https://www.mlflow.org/docs/latest/rest-api.html#transition-modelversion-stage`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(4),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
transitionStageReq.Name = args[0]
transitionStageReq.Version = args[1]
_, err = fmt.Sscan(args[2], &transitionStageReq.Stage)
if err != nil {
return fmt.Errorf("invalid STAGE: %s", args[2])
}
_, err = fmt.Sscan(args[3], &transitionStageReq.ArchiveExistingVersions)
if err != nil {
return fmt.Errorf("invalid ARCHIVE_EXISTING_VERSIONS: %s", args[3])
}
response, err := w.ModelRegistry.TransitionStage(ctx, transitionStageReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
},
}
// start update-comment command
var updateCommentReq ml.UpdateComment
func init() {
Cmd.AddCommand(updateCommentCmd)
// TODO: short flags
}
var updateCommentCmd = &cobra.Command{
Use: "update-comment ID COMMENT",
Short: `Update a comment.`,
Long: `Update a comment.
Post an edit to a comment on a model version.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(2),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
updateCommentReq.Id = args[0]
updateCommentReq.Comment = args[1]
response, err := w.ModelRegistry.UpdateComment(ctx, updateCommentReq)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
},
}
// start update-model command
var updateModelReq ml.UpdateModelRequest
func init() {
Cmd.AddCommand(updateModelCmd)
// TODO: short flags
updateModelCmd.Flags().StringVar(&updateModelReq.Description, "description", updateModelReq.Description, `If provided, updates the description for this registered_model.`)
}
var updateModelCmd = &cobra.Command{
Use: "update-model NAME",
Short: `Update model.`,
Long: `Update model.
Updates a registered model.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(1),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
updateModelReq.Name = args[0]
err = w.ModelRegistry.UpdateModel(ctx, updateModelReq)
if err != nil {
return err
}
return nil
},
}
// start update-model-version command
var updateModelVersionReq ml.UpdateModelVersionRequest
func init() {
Cmd.AddCommand(updateModelVersionCmd)
// TODO: short flags
updateModelVersionCmd.Flags().StringVar(&updateModelVersionReq.Description, "description", updateModelVersionReq.Description, `If provided, updates the description for this registered_model.`)
}
var updateModelVersionCmd = &cobra.Command{
Use: "update-model-version NAME VERSION",
Short: `Update model version.`,
Long: `Update model version.
Updates the model version.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(2),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
updateModelVersionReq.Name = args[0]
updateModelVersionReq.Version = args[1]
err = w.ModelRegistry.UpdateModelVersion(ctx, updateModelVersionReq)
if err != nil {
return err
}
return nil
},
}
// start update-webhook command
var updateWebhookReq ml.UpdateRegistryWebhook
var updateWebhookJson flags.JsonFlag
func init() {
Cmd.AddCommand(updateWebhookCmd)
// TODO: short flags
updateWebhookCmd.Flags().Var(&updateWebhookJson, "json", `either inline JSON string or @path/to/file.json with request body`)
updateWebhookCmd.Flags().StringVar(&updateWebhookReq.Description, "description", updateWebhookReq.Description, `User-specified description for the webhook.`)
// TODO: array: events
// TODO: complex arg: http_url_spec
// TODO: complex arg: job_spec
updateWebhookCmd.Flags().Var(&updateWebhookReq.Status, "status", `This describes an enum.`)
}
var updateWebhookCmd = &cobra.Command{
Use: "update-webhook",
Short: `Update a webhook.`,
Long: `Update a webhook.
**NOTE:** This endpoint is in Public Preview.
Updates a registry webhook.`,
Annotations: map[string]string{},
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
err = updateWebhookJson.Unmarshal(&updateWebhookReq)
if err != nil {
return err
}
updateWebhookReq.Id = args[0]
err = w.ModelRegistry.UpdateWebhook(ctx, updateWebhookReq)
if err != nil {
return err
}
return nil
},
}
// end service ModelRegistry