From 36d099b474a88ebc8d5834fe468cb57ca05ac65f Mon Sep 17 00:00:00 2001 From: Parth Bansal Date: Fri, 3 Oct 2025 14:48:42 +0000 Subject: [PATCH 1/9] initial update --- .codegen/_openapi_sha | 2 +- .gitattributes | 5 + .gitignore | 2 + cmd/account/budget-policy/budget-policy.go | 1 + cmd/account/cmd.go | 2 + cmd/account/credentials/credentials.go | 58 +- .../encryption-keys/encryption-keys.go | 22 +- cmd/account/iam-v2/iam-v2.go | 1332 ++++++++++++++++- .../metastore-assignments.go | 18 +- cmd/account/metastores/metastores.go | 8 +- .../network-connectivity.go | 2 + cmd/account/networks/networks.go | 82 +- cmd/account/private-access/private-access.go | 206 +-- .../storage-credentials.go | 19 +- cmd/account/storage/storage.go | 90 +- cmd/account/usage-policy/usage-policy.go | 362 +++++ cmd/account/vpc-endpoints/vpc-endpoints.go | 105 +- cmd/account/workspaces/workspaces.go | 340 ++--- cmd/workspace/apps/apps.go | 183 +++ cmd/workspace/catalogs/catalogs.go | 5 + cmd/workspace/cmd.go | 8 + cmd/workspace/connections/connections.go | 2 + cmd/workspace/credentials/credentials.go | 1 + cmd/workspace/data-quality/data-quality.go | 891 +++++++++++ .../database-project/database-project.go | 1062 +++++++++++++ cmd/workspace/database/database.go | 192 ++- cmd/workspace/experiments/experiments.go | 54 + .../external-locations/external-locations.go | 1 + .../external-metadata/external-metadata.go | 2 + cmd/workspace/functions/functions.go | 8 +- cmd/workspace/genie/genie.go | 312 ++++ cmd/workspace/grants/grants.go | 1 + .../instance-pools/instance-pools.go | 4 + .../lakeview-embedded/lakeview-embedded.go | 57 + cmd/workspace/libraries/libraries.go | 447 ++++++ .../model-versions/model-versions.go | 16 + cmd/workspace/permissions/permissions.go | 16 +- cmd/workspace/pipelines/pipelines.go | 138 ++ .../query-execution/query-execution.go | 242 +++ .../registered-models/registered-models.go | 58 +- .../serving-endpoints/serving-endpoints.go | 75 + cmd/workspace/shares/shares.go | 2 + .../storage-credentials.go | 1 + .../tag-assignments/tag-assignments.go | 418 ++++++ .../vector-search-endpoints.go | 1 + .../vector-search-indexes.go | 57 + cmd/workspace/volumes/volumes.go | 9 +- cmd/workspace/warehouses/warehouses.go | 15 +- .../workspace-iam-v2/workspace-iam-v2.go | 1330 +++++++++++++++- cmd/workspace/workspace/workspace.go | 1 + go.mod | 2 + 51 files changed, 7497 insertions(+), 770 deletions(-) create mode 100755 cmd/account/usage-policy/usage-policy.go create mode 100755 cmd/workspace/data-quality/data-quality.go create mode 100755 cmd/workspace/database-project/database-project.go create mode 100755 cmd/workspace/query-execution/query-execution.go create mode 100755 cmd/workspace/tag-assignments/tag-assignments.go diff --git a/.codegen/_openapi_sha b/.codegen/_openapi_sha index bdd95ecce2..220391b552 100644 --- a/.codegen/_openapi_sha +++ b/.codegen/_openapi_sha @@ -1 +1 @@ -f2843dd06e095a39dda2d454a97ceaf6767a2bf3 \ No newline at end of file +universe:/home/parth.bansal/v0/universe \ No newline at end of file diff --git a/.gitattributes b/.gitattributes index df4740a1f1..5879941848 100755 --- a/.gitattributes +++ b/.gitattributes @@ -34,6 +34,7 @@ cmd/account/settings/settings.go linguist-generated=true cmd/account/storage-credentials/storage-credentials.go linguist-generated=true cmd/account/storage/storage.go linguist-generated=true cmd/account/usage-dashboards/usage-dashboards.go linguist-generated=true +cmd/account/usage-policy/usage-policy.go linguist-generated=true cmd/account/users-v2/users-v2.go linguist-generated=true cmd/account/vpc-endpoints/vpc-endpoints.go linguist-generated=true cmd/account/workspace-assignment/workspace-assignment.go linguist-generated=true @@ -72,7 +73,9 @@ cmd/workspace/current-user/current-user.go linguist-generated=true cmd/workspace/dashboard-email-subscriptions/dashboard-email-subscriptions.go linguist-generated=true cmd/workspace/dashboard-widgets/dashboard-widgets.go linguist-generated=true cmd/workspace/dashboards/dashboards.go linguist-generated=true +cmd/workspace/data-quality/data-quality.go linguist-generated=true cmd/workspace/data-sources/data-sources.go linguist-generated=true +cmd/workspace/database-project/database-project.go linguist-generated=true cmd/workspace/database/database.go linguist-generated=true cmd/workspace/default-namespace/default-namespace.go linguist-generated=true cmd/workspace/default-warehouse-id/default-warehouse-id.go linguist-generated=true @@ -129,6 +132,7 @@ cmd/workspace/quality-monitor-v2/quality-monitor-v2.go linguist-generated=true cmd/workspace/quality-monitors/quality-monitors.go linguist-generated=true cmd/workspace/queries-legacy/queries-legacy.go linguist-generated=true cmd/workspace/queries/queries.go linguist-generated=true +cmd/workspace/query-execution/query-execution.go linguist-generated=true cmd/workspace/query-history/query-history.go linguist-generated=true cmd/workspace/query-visualizations-legacy/query-visualizations-legacy.go linguist-generated=true cmd/workspace/query-visualizations/query-visualizations.go linguist-generated=true @@ -153,6 +157,7 @@ cmd/workspace/storage-credentials/storage-credentials.go linguist-generated=true cmd/workspace/system-schemas/system-schemas.go linguist-generated=true cmd/workspace/table-constraints/table-constraints.go linguist-generated=true cmd/workspace/tables/tables.go linguist-generated=true +cmd/workspace/tag-assignments/tag-assignments.go linguist-generated=true cmd/workspace/tag-policies/tag-policies.go linguist-generated=true cmd/workspace/temporary-path-credentials/temporary-path-credentials.go linguist-generated=true cmd/workspace/temporary-table-credentials/temporary-table-credentials.go linguist-generated=true diff --git a/.gitignore b/.gitignore index 4b9fe855d5..e692d23d98 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,5 @@ tools/yamlfmt.exe # Release artifacts dist/ + +vendor/ \ No newline at end of file diff --git a/cmd/account/budget-policy/budget-policy.go b/cmd/account/budget-policy/budget-policy.go index a921d9ddfd..9a576ff9a3 100755 --- a/cmd/account/budget-policy/budget-policy.go +++ b/cmd/account/budget-policy/budget-policy.go @@ -297,6 +297,7 @@ func newUpdate() *cobra.Command { cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: limit_config + cmd.Flags().StringVar(&updateReq.UpdateMask, "update-mask", updateReq.UpdateMask, `Field mask specifying which fields to update.`) // TODO: array: binding_workspace_ids // TODO: array: custom_tags cmd.Flags().StringVar(&updateReq.Policy.PolicyName, "policy-name", updateReq.Policy.PolicyName, `The name of the policy.`) diff --git a/cmd/account/cmd.go b/cmd/account/cmd.go index d5f27f2b8f..de152f3719 100644 --- a/cmd/account/cmd.go +++ b/cmd/account/cmd.go @@ -33,6 +33,7 @@ import ( storage "github.com/databricks/cli/cmd/account/storage" account_storage_credentials "github.com/databricks/cli/cmd/account/storage-credentials" usage_dashboards "github.com/databricks/cli/cmd/account/usage-dashboards" + usage_policy "github.com/databricks/cli/cmd/account/usage-policy" account_users_v2 "github.com/databricks/cli/cmd/account/users-v2" vpc_endpoints "github.com/databricks/cli/cmd/account/vpc-endpoints" workspace_assignment "github.com/databricks/cli/cmd/account/workspace-assignment" @@ -76,6 +77,7 @@ func New() *cobra.Command { cmd.AddCommand(storage.New()) cmd.AddCommand(account_storage_credentials.New()) cmd.AddCommand(usage_dashboards.New()) + cmd.AddCommand(usage_policy.New()) cmd.AddCommand(account_users_v2.New()) cmd.AddCommand(vpc_endpoints.New()) cmd.AddCommand(workspace_assignment.New()) diff --git a/cmd/account/credentials/credentials.go b/cmd/account/credentials/credentials.go index a0873e3a0f..65d5e6bfef 100755 --- a/cmd/account/credentials/credentials.go +++ b/cmd/account/credentials/credentials.go @@ -151,35 +151,23 @@ func newDelete() *cobra.Command { cmd.Annotations = make(map[string]string) + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) - if len(args) == 0 { - promptSpinner := cmdio.Spinner(ctx) - promptSpinner <- "No CREDENTIALS_ID argument specified. Loading names for Credentials drop-down." - names, err := a.Credentials.CredentialCredentialsNameToCredentialsIdMap(ctx) - close(promptSpinner) - if err != nil { - return fmt.Errorf("failed to load names for Credentials drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Databricks Account API credential configuration ID") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have databricks account api credential configuration id") - } deleteReq.CredentialsId = args[0] - err = a.Credentials.Delete(ctx, deleteReq) + response, err := a.Credentials.Delete(ctx, deleteReq) if err != nil { return err } - return nil + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -216,32 +204,20 @@ func newGet() *cobra.Command { specified by ID. Arguments: - CREDENTIALS_ID: Databricks Account API credential configuration ID` + CREDENTIALS_ID: Credential configuration ID` cmd.Annotations = make(map[string]string) + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) - if len(args) == 0 { - promptSpinner := cmdio.Spinner(ctx) - promptSpinner <- "No CREDENTIALS_ID argument specified. Loading names for Credentials drop-down." - names, err := a.Credentials.CredentialCredentialsNameToCredentialsIdMap(ctx) - close(promptSpinner) - if err != nil { - return fmt.Errorf("failed to load names for Credentials drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Databricks Account API credential configuration ID") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have databricks account api credential configuration id") - } getReq.CredentialsId = args[0] response, err := a.Credentials.Get(ctx, getReq) @@ -275,11 +251,11 @@ func newList() *cobra.Command { cmd := &cobra.Command{} cmd.Use = "list" - cmd.Short = `Get all credential configurations.` - cmd.Long = `Get all credential configurations. + cmd.Short = `List credential configuration.` + cmd.Long = `List credential configuration. - Gets all Databricks credential configurations associated with an account - specified by ID.` + List Databricks credential configuration objects for an account, specified by + ID.` cmd.Annotations = make(map[string]string) diff --git a/cmd/account/encryption-keys/encryption-keys.go b/cmd/account/encryption-keys/encryption-keys.go index 23a733903d..5645dec927 100755 --- a/cmd/account/encryption-keys/encryption-keys.go +++ b/cmd/account/encryption-keys/encryption-keys.go @@ -179,11 +179,11 @@ func newDelete() *cobra.Command { deleteReq.CustomerManagedKeyId = args[0] - err = a.EncryptionKeys.Delete(ctx, deleteReq) + response, err := a.EncryptionKeys.Delete(ctx, deleteReq) if err != nil { return err } - return nil + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -280,22 +280,10 @@ func newList() *cobra.Command { cmd := &cobra.Command{} cmd.Use = "list" - cmd.Short = `Get all encryption key configurations.` - cmd.Long = `Get all encryption key configurations. - - Gets all customer-managed key configuration objects for an account. If the key - is specified as a workspace's managed services customer-managed key, - Databricks uses the key to encrypt the workspace's notebooks and secrets in - the control plane, in addition to Databricks SQL queries and query history. If - the key is specified as a workspace's storage customer-managed key, the key is - used to encrypt the workspace's root S3 bucket and optionally can encrypt - cluster EBS volumes data in the data plane. - - **Important**: Customer-managed keys are supported only for some deployment - types, subscription types, and AWS regions. + cmd.Short = `List encryption key configuration.` + cmd.Long = `List encryption key configuration. - This operation is available only if your account is on the E2 version of the - platform.` + Lists Databricks customer-managed key configurations for an account.` cmd.Annotations = make(map[string]string) diff --git a/cmd/account/iam-v2/iam-v2.go b/cmd/account/iam-v2/iam-v2.go index 528f8efcc9..71c5d74a9d 100755 --- a/cmd/account/iam-v2/iam-v2.go +++ b/cmd/account/iam-v2/iam-v2.go @@ -31,10 +31,29 @@ func New() *cobra.Command { } // Add methods + cmd.AddCommand(newCreateGroup()) + cmd.AddCommand(newCreateServicePrincipal()) + cmd.AddCommand(newCreateUser()) + cmd.AddCommand(newCreateWorkspaceAccessDetail()) + cmd.AddCommand(newDeleteGroup()) + cmd.AddCommand(newDeleteServicePrincipal()) + cmd.AddCommand(newDeleteUser()) + cmd.AddCommand(newDeleteWorkspaceAccessDetail()) + cmd.AddCommand(newGetGroup()) + cmd.AddCommand(newGetServicePrincipal()) + cmd.AddCommand(newGetUser()) cmd.AddCommand(newGetWorkspaceAccessDetail()) + cmd.AddCommand(newListGroups()) + cmd.AddCommand(newListServicePrincipals()) + cmd.AddCommand(newListUsers()) + cmd.AddCommand(newListWorkspaceAccessDetails()) cmd.AddCommand(newResolveGroup()) cmd.AddCommand(newResolveServicePrincipal()) cmd.AddCommand(newResolveUser()) + cmd.AddCommand(newUpdateGroup()) + cmd.AddCommand(newUpdateServicePrincipal()) + cmd.AddCommand(newUpdateUser()) + cmd.AddCommand(newUpdateWorkspaceAccessDetail()) // Apply optional overrides to this command. for _, fn := range cmdOverrides { @@ -44,6 +63,729 @@ func New() *cobra.Command { return cmd } +// start create-group command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var createGroupOverrides []func( + *cobra.Command, + *iamv2.CreateGroupRequest, +) + +func newCreateGroup() *cobra.Command { + cmd := &cobra.Command{} + + var createGroupReq iamv2.CreateGroupRequest + createGroupReq.Group = iamv2.Group{} + var createGroupJson flags.JsonFlag + + cmd.Flags().Var(&createGroupJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&createGroupReq.Group.ExternalId, "external-id", createGroupReq.Group.ExternalId, `ExternalId of the group in the customer's IdP.`) + cmd.Flags().StringVar(&createGroupReq.Group.GroupName, "group-name", createGroupReq.Group.GroupName, `Display name of the group.`) + + cmd.Use = "create-group" + cmd.Short = `Create a group in the account.` + cmd.Long = `Create a group in the account. + + TODO: Write description later when this method is implemented` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(0) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + if cmd.Flags().Changed("json") { + diags := createGroupJson.Unmarshal(&createGroupReq.Group) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + + response, err := a.IamV2.CreateGroup(ctx, createGroupReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range createGroupOverrides { + fn(cmd, &createGroupReq) + } + + return cmd +} + +// start create-service-principal command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var createServicePrincipalOverrides []func( + *cobra.Command, + *iamv2.CreateServicePrincipalRequest, +) + +func newCreateServicePrincipal() *cobra.Command { + cmd := &cobra.Command{} + + var createServicePrincipalReq iamv2.CreateServicePrincipalRequest + createServicePrincipalReq.ServicePrincipal = iamv2.ServicePrincipal{} + var createServicePrincipalJson flags.JsonFlag + + cmd.Flags().Var(&createServicePrincipalJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().Var(&createServicePrincipalReq.ServicePrincipal.AccountSpStatus, "account-sp-status", `The activity status of a service principal in a Databricks account. Supported values: [ACTIVE, INACTIVE]`) + cmd.Flags().StringVar(&createServicePrincipalReq.ServicePrincipal.ApplicationId, "application-id", createServicePrincipalReq.ServicePrincipal.ApplicationId, `Application ID of the service principal.`) + cmd.Flags().StringVar(&createServicePrincipalReq.ServicePrincipal.DisplayName, "display-name", createServicePrincipalReq.ServicePrincipal.DisplayName, `Display name of the service principal.`) + cmd.Flags().StringVar(&createServicePrincipalReq.ServicePrincipal.ExternalId, "external-id", createServicePrincipalReq.ServicePrincipal.ExternalId, `ExternalId of the service principal in the customer's IdP.`) + + cmd.Use = "create-service-principal" + cmd.Short = `Create a service principal in the account.` + cmd.Long = `Create a service principal in the account. + + TODO: Write description later when this method is implemented` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(0) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + if cmd.Flags().Changed("json") { + diags := createServicePrincipalJson.Unmarshal(&createServicePrincipalReq.ServicePrincipal) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + + response, err := a.IamV2.CreateServicePrincipal(ctx, createServicePrincipalReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range createServicePrincipalOverrides { + fn(cmd, &createServicePrincipalReq) + } + + return cmd +} + +// start create-user command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var createUserOverrides []func( + *cobra.Command, + *iamv2.CreateUserRequest, +) + +func newCreateUser() *cobra.Command { + cmd := &cobra.Command{} + + var createUserReq iamv2.CreateUserRequest + createUserReq.User = iamv2.User{} + var createUserJson flags.JsonFlag + + cmd.Flags().Var(&createUserJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().Var(&createUserReq.User.AccountUserStatus, "account-user-status", `The activity status of a user in a Databricks account. Supported values: [ACTIVE, INACTIVE]`) + cmd.Flags().StringVar(&createUserReq.User.ExternalId, "external-id", createUserReq.User.ExternalId, `ExternalId of the user in the customer's IdP.`) + // TODO: complex arg: name + + cmd.Use = "create-user USERNAME" + cmd.Short = `Create a user in the account.` + cmd.Long = `Create a user in the account. + + TODO: Write description later when this method is implemented + + Arguments: + USERNAME: Username/email of the user.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + if cmd.Flags().Changed("json") { + err := root.ExactArgs(0)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'username' in your JSON input") + } + return nil + } + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + if cmd.Flags().Changed("json") { + diags := createUserJson.Unmarshal(&createUserReq.User) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + if !cmd.Flags().Changed("json") { + createUserReq.User.Username = args[0] + } + + response, err := a.IamV2.CreateUser(ctx, createUserReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range createUserOverrides { + fn(cmd, &createUserReq) + } + + return cmd +} + +// start create-workspace-access-detail command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var createWorkspaceAccessDetailOverrides []func( + *cobra.Command, + *iamv2.CreateWorkspaceAccessDetailRequest, +) + +func newCreateWorkspaceAccessDetail() *cobra.Command { + cmd := &cobra.Command{} + + var createWorkspaceAccessDetailReq iamv2.CreateWorkspaceAccessDetailRequest + createWorkspaceAccessDetailReq.WorkspaceAccessDetail = iamv2.WorkspaceAccessDetail{} + var createWorkspaceAccessDetailJson flags.JsonFlag + + cmd.Flags().Var(&createWorkspaceAccessDetailJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + // TODO: array: permissions + cmd.Flags().Var(&createWorkspaceAccessDetailReq.WorkspaceAccessDetail.Status, "status", `The activity status of the principal in the workspace. Supported values: [ACTIVE, INACTIVE]`) + + cmd.Use = "create-workspace-access-detail PARENT" + cmd.Short = `Define workspace access for a principal.` + cmd.Long = `Define workspace access for a principal. + + TODO: Write description later when this method is implemented + + Arguments: + PARENT: Required. The parent path for workspace access detail.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + if cmd.Flags().Changed("json") { + diags := createWorkspaceAccessDetailJson.Unmarshal(&createWorkspaceAccessDetailReq.WorkspaceAccessDetail) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + createWorkspaceAccessDetailReq.Parent = args[0] + + response, err := a.IamV2.CreateWorkspaceAccessDetail(ctx, createWorkspaceAccessDetailReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range createWorkspaceAccessDetailOverrides { + fn(cmd, &createWorkspaceAccessDetailReq) + } + + return cmd +} + +// start delete-group command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var deleteGroupOverrides []func( + *cobra.Command, + *iamv2.DeleteGroupRequest, +) + +func newDeleteGroup() *cobra.Command { + cmd := &cobra.Command{} + + var deleteGroupReq iamv2.DeleteGroupRequest + + cmd.Use = "delete-group INTERNAL_ID" + cmd.Short = `Delete a group in the account.` + cmd.Long = `Delete a group in the account. + + TODO: Write description later when this method is implemented + + Arguments: + INTERNAL_ID: Required. Internal ID of the group in Databricks.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + _, err = fmt.Sscan(args[0], &deleteGroupReq.InternalId) + if err != nil { + return fmt.Errorf("invalid INTERNAL_ID: %s", args[0]) + } + + err = a.IamV2.DeleteGroup(ctx, deleteGroupReq) + if err != nil { + return err + } + return nil + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range deleteGroupOverrides { + fn(cmd, &deleteGroupReq) + } + + return cmd +} + +// start delete-service-principal command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var deleteServicePrincipalOverrides []func( + *cobra.Command, + *iamv2.DeleteServicePrincipalRequest, +) + +func newDeleteServicePrincipal() *cobra.Command { + cmd := &cobra.Command{} + + var deleteServicePrincipalReq iamv2.DeleteServicePrincipalRequest + + cmd.Use = "delete-service-principal INTERNAL_ID" + cmd.Short = `Delete a service principal in the account.` + cmd.Long = `Delete a service principal in the account. + + TODO: Write description later when this method is implemented + + Arguments: + INTERNAL_ID: Required. Internal ID of the service principal in Databricks.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + _, err = fmt.Sscan(args[0], &deleteServicePrincipalReq.InternalId) + if err != nil { + return fmt.Errorf("invalid INTERNAL_ID: %s", args[0]) + } + + err = a.IamV2.DeleteServicePrincipal(ctx, deleteServicePrincipalReq) + if err != nil { + return err + } + return nil + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range deleteServicePrincipalOverrides { + fn(cmd, &deleteServicePrincipalReq) + } + + return cmd +} + +// start delete-user command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var deleteUserOverrides []func( + *cobra.Command, + *iamv2.DeleteUserRequest, +) + +func newDeleteUser() *cobra.Command { + cmd := &cobra.Command{} + + var deleteUserReq iamv2.DeleteUserRequest + + cmd.Use = "delete-user INTERNAL_ID" + cmd.Short = `Delete a user in the account.` + cmd.Long = `Delete a user in the account. + + TODO: Write description later when this method is implemented + + Arguments: + INTERNAL_ID: Required. Internal ID of the user in Databricks.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + _, err = fmt.Sscan(args[0], &deleteUserReq.InternalId) + if err != nil { + return fmt.Errorf("invalid INTERNAL_ID: %s", args[0]) + } + + err = a.IamV2.DeleteUser(ctx, deleteUserReq) + if err != nil { + return err + } + return nil + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range deleteUserOverrides { + fn(cmd, &deleteUserReq) + } + + return cmd +} + +// start delete-workspace-access-detail command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var deleteWorkspaceAccessDetailOverrides []func( + *cobra.Command, + *iamv2.DeleteWorkspaceAccessDetailRequest, +) + +func newDeleteWorkspaceAccessDetail() *cobra.Command { + cmd := &cobra.Command{} + + var deleteWorkspaceAccessDetailReq iamv2.DeleteWorkspaceAccessDetailRequest + + cmd.Use = "delete-workspace-access-detail WORKSPACE_ID PRINCIPAL_ID" + cmd.Short = `Delete workspace access for a principal.` + cmd.Long = `Delete workspace access for a principal. + + TODO: Write description later when this method is implemented + + Arguments: + WORKSPACE_ID: The workspace ID where the principal has access. + PRINCIPAL_ID: Required. ID of the principal in Databricks to delete workspace access + for.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + _, err = fmt.Sscan(args[0], &deleteWorkspaceAccessDetailReq.WorkspaceId) + if err != nil { + return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) + } + _, err = fmt.Sscan(args[1], &deleteWorkspaceAccessDetailReq.PrincipalId) + if err != nil { + return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[1]) + } + + err = a.IamV2.DeleteWorkspaceAccessDetail(ctx, deleteWorkspaceAccessDetailReq) + if err != nil { + return err + } + return nil + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range deleteWorkspaceAccessDetailOverrides { + fn(cmd, &deleteWorkspaceAccessDetailReq) + } + + return cmd +} + +// start get-group command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var getGroupOverrides []func( + *cobra.Command, + *iamv2.GetGroupRequest, +) + +func newGetGroup() *cobra.Command { + cmd := &cobra.Command{} + + var getGroupReq iamv2.GetGroupRequest + + cmd.Use = "get-group INTERNAL_ID" + cmd.Short = `Get a group in the account.` + cmd.Long = `Get a group in the account. + + TODO: Write description later when this method is implemented + + Arguments: + INTERNAL_ID: Required. Internal ID of the group in Databricks.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + _, err = fmt.Sscan(args[0], &getGroupReq.InternalId) + if err != nil { + return fmt.Errorf("invalid INTERNAL_ID: %s", args[0]) + } + + response, err := a.IamV2.GetGroup(ctx, getGroupReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range getGroupOverrides { + fn(cmd, &getGroupReq) + } + + return cmd +} + +// start get-service-principal command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var getServicePrincipalOverrides []func( + *cobra.Command, + *iamv2.GetServicePrincipalRequest, +) + +func newGetServicePrincipal() *cobra.Command { + cmd := &cobra.Command{} + + var getServicePrincipalReq iamv2.GetServicePrincipalRequest + + cmd.Use = "get-service-principal INTERNAL_ID" + cmd.Short = `Get a service principal in the account.` + cmd.Long = `Get a service principal in the account. + + TODO: Write description later when this method is implemented + + Arguments: + INTERNAL_ID: Required. Internal ID of the service principal in Databricks.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + _, err = fmt.Sscan(args[0], &getServicePrincipalReq.InternalId) + if err != nil { + return fmt.Errorf("invalid INTERNAL_ID: %s", args[0]) + } + + response, err := a.IamV2.GetServicePrincipal(ctx, getServicePrincipalReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range getServicePrincipalOverrides { + fn(cmd, &getServicePrincipalReq) + } + + return cmd +} + +// start get-user command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var getUserOverrides []func( + *cobra.Command, + *iamv2.GetUserRequest, +) + +func newGetUser() *cobra.Command { + cmd := &cobra.Command{} + + var getUserReq iamv2.GetUserRequest + + cmd.Use = "get-user INTERNAL_ID" + cmd.Short = `Get a user in the account.` + cmd.Long = `Get a user in the account. + + TODO: Write description later when this method is implemented + + Arguments: + INTERNAL_ID: Required. Internal ID of the user in Databricks.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + _, err = fmt.Sscan(args[0], &getUserReq.InternalId) + if err != nil { + return fmt.Errorf("invalid INTERNAL_ID: %s", args[0]) + } + + response, err := a.IamV2.GetUser(ctx, getUserReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range getUserOverrides { + fn(cmd, &getUserReq) + } + + return cmd +} + // start get-workspace-access-detail command // Slice with functions to override default command behavior. @@ -72,15 +814,243 @@ func newGetWorkspaceAccessDetail() *cobra.Command { what fields are returned (BASIC by default or FULL). Arguments: - WORKSPACE_ID: Required. The workspace ID for which the access details are being - requested. - PRINCIPAL_ID: Required. The internal ID of the principal (user/sp/group) for which the - access details are being requested.` + WORKSPACE_ID: Required. The workspace ID for which the access details are being + requested. + PRINCIPAL_ID: Required. The internal ID of the principal (user/sp/group) for which the + access details are being requested.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + _, err = fmt.Sscan(args[0], &getWorkspaceAccessDetailReq.WorkspaceId) + if err != nil { + return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) + } + _, err = fmt.Sscan(args[1], &getWorkspaceAccessDetailReq.PrincipalId) + if err != nil { + return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[1]) + } + + response, err := a.IamV2.GetWorkspaceAccessDetail(ctx, getWorkspaceAccessDetailReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range getWorkspaceAccessDetailOverrides { + fn(cmd, &getWorkspaceAccessDetailReq) + } + + return cmd +} + +// start list-groups command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var listGroupsOverrides []func( + *cobra.Command, + *iamv2.ListGroupsRequest, +) + +func newListGroups() *cobra.Command { + cmd := &cobra.Command{} + + var listGroupsReq iamv2.ListGroupsRequest + + cmd.Flags().IntVar(&listGroupsReq.PageSize, "page-size", listGroupsReq.PageSize, `The maximum number of groups to return.`) + cmd.Flags().StringVar(&listGroupsReq.PageToken, "page-token", listGroupsReq.PageToken, `A page token, received from a previous ListGroups call.`) + + cmd.Use = "list-groups" + cmd.Short = `List groups in the account.` + cmd.Long = `List groups in the account. + + TODO: Write description later when this method is implemented` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(0) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + response, err := a.IamV2.ListGroups(ctx, listGroupsReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range listGroupsOverrides { + fn(cmd, &listGroupsReq) + } + + return cmd +} + +// start list-service-principals command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var listServicePrincipalsOverrides []func( + *cobra.Command, + *iamv2.ListServicePrincipalsRequest, +) + +func newListServicePrincipals() *cobra.Command { + cmd := &cobra.Command{} + + var listServicePrincipalsReq iamv2.ListServicePrincipalsRequest + + cmd.Flags().IntVar(&listServicePrincipalsReq.PageSize, "page-size", listServicePrincipalsReq.PageSize, `The maximum number of service principals to return.`) + cmd.Flags().StringVar(&listServicePrincipalsReq.PageToken, "page-token", listServicePrincipalsReq.PageToken, `A page token, received from a previous ListServicePrincipals call.`) + + cmd.Use = "list-service-principals" + cmd.Short = `List service principals in the account.` + cmd.Long = `List service principals in the account. + + TODO: Write description later when this method is implemented` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(0) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + response, err := a.IamV2.ListServicePrincipals(ctx, listServicePrincipalsReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range listServicePrincipalsOverrides { + fn(cmd, &listServicePrincipalsReq) + } + + return cmd +} + +// start list-users command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var listUsersOverrides []func( + *cobra.Command, + *iamv2.ListUsersRequest, +) + +func newListUsers() *cobra.Command { + cmd := &cobra.Command{} + + var listUsersReq iamv2.ListUsersRequest + + cmd.Flags().IntVar(&listUsersReq.PageSize, "page-size", listUsersReq.PageSize, `The maximum number of users to return.`) + cmd.Flags().StringVar(&listUsersReq.PageToken, "page-token", listUsersReq.PageToken, `A page token, received from a previous ListUsers call.`) + + cmd.Use = "list-users" + cmd.Short = `List users in the account.` + cmd.Long = `List users in the account. + + TODO: Write description later when this method is implemented` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(0) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + response, err := a.IamV2.ListUsers(ctx, listUsersReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range listUsersOverrides { + fn(cmd, &listUsersReq) + } + + return cmd +} + +// start list-workspace-access-details command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var listWorkspaceAccessDetailsOverrides []func( + *cobra.Command, + *iamv2.ListWorkspaceAccessDetailsRequest, +) + +func newListWorkspaceAccessDetails() *cobra.Command { + cmd := &cobra.Command{} + + var listWorkspaceAccessDetailsReq iamv2.ListWorkspaceAccessDetailsRequest + + cmd.Flags().IntVar(&listWorkspaceAccessDetailsReq.PageSize, "page-size", listWorkspaceAccessDetailsReq.PageSize, `The maximum number of workspace access details to return.`) + cmd.Flags().StringVar(&listWorkspaceAccessDetailsReq.PageToken, "page-token", listWorkspaceAccessDetailsReq.PageToken, `A page token, received from a previous ListWorkspaceAccessDetails call.`) + + cmd.Use = "list-workspace-access-details WORKSPACE_ID" + cmd.Short = `List workspace access details for a workspace.` + cmd.Long = `List workspace access details for a workspace. + + TODO: Write description later when this method is implemented + + Arguments: + WORKSPACE_ID: The workspace ID for which the workspace access details are being fetched.` cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { - check := root.ExactArgs(2) + check := root.ExactArgs(1) return check(cmd, args) } @@ -89,16 +1059,12 @@ func newGetWorkspaceAccessDetail() *cobra.Command { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) - _, err = fmt.Sscan(args[0], &getWorkspaceAccessDetailReq.WorkspaceId) + _, err = fmt.Sscan(args[0], &listWorkspaceAccessDetailsReq.WorkspaceId) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } - _, err = fmt.Sscan(args[1], &getWorkspaceAccessDetailReq.PrincipalId) - if err != nil { - return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[1]) - } - response, err := a.IamV2.GetWorkspaceAccessDetail(ctx, getWorkspaceAccessDetailReq) + response, err := a.IamV2.ListWorkspaceAccessDetails(ctx, listWorkspaceAccessDetailsReq) if err != nil { return err } @@ -110,8 +1076,8 @@ func newGetWorkspaceAccessDetail() *cobra.Command { cmd.ValidArgsFunction = cobra.NoFileCompletions // Apply optional overrides to this command. - for _, fn := range getWorkspaceAccessDetailOverrides { - fn(cmd, &getWorkspaceAccessDetailReq) + for _, fn := range listWorkspaceAccessDetailsOverrides { + fn(cmd, &listWorkspaceAccessDetailsReq) } return cmd @@ -364,4 +1330,344 @@ func newResolveUser() *cobra.Command { return cmd } +// start update-group command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var updateGroupOverrides []func( + *cobra.Command, + *iamv2.UpdateGroupRequest, +) + +func newUpdateGroup() *cobra.Command { + cmd := &cobra.Command{} + + var updateGroupReq iamv2.UpdateGroupRequest + updateGroupReq.Group = iamv2.Group{} + var updateGroupJson flags.JsonFlag + + cmd.Flags().Var(&updateGroupJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&updateGroupReq.Group.ExternalId, "external-id", updateGroupReq.Group.ExternalId, `ExternalId of the group in the customer's IdP.`) + cmd.Flags().StringVar(&updateGroupReq.Group.GroupName, "group-name", updateGroupReq.Group.GroupName, `Display name of the group.`) + + cmd.Use = "update-group INTERNAL_ID UPDATE_MASK" + cmd.Short = `Update a group in the account.` + cmd.Long = `Update a group in the account. + + TODO: Write description later when this method is implemented + + Arguments: + INTERNAL_ID: Required. Internal ID of the group in Databricks. + UPDATE_MASK: Optional. The list of fields to update.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + if cmd.Flags().Changed("json") { + diags := updateGroupJson.Unmarshal(&updateGroupReq.Group) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + _, err = fmt.Sscan(args[0], &updateGroupReq.InternalId) + if err != nil { + return fmt.Errorf("invalid INTERNAL_ID: %s", args[0]) + } + updateGroupReq.UpdateMask = args[1] + + response, err := a.IamV2.UpdateGroup(ctx, updateGroupReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range updateGroupOverrides { + fn(cmd, &updateGroupReq) + } + + return cmd +} + +// start update-service-principal command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var updateServicePrincipalOverrides []func( + *cobra.Command, + *iamv2.UpdateServicePrincipalRequest, +) + +func newUpdateServicePrincipal() *cobra.Command { + cmd := &cobra.Command{} + + var updateServicePrincipalReq iamv2.UpdateServicePrincipalRequest + updateServicePrincipalReq.ServicePrincipal = iamv2.ServicePrincipal{} + var updateServicePrincipalJson flags.JsonFlag + + cmd.Flags().Var(&updateServicePrincipalJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().Var(&updateServicePrincipalReq.ServicePrincipal.AccountSpStatus, "account-sp-status", `The activity status of a service principal in a Databricks account. Supported values: [ACTIVE, INACTIVE]`) + cmd.Flags().StringVar(&updateServicePrincipalReq.ServicePrincipal.ApplicationId, "application-id", updateServicePrincipalReq.ServicePrincipal.ApplicationId, `Application ID of the service principal.`) + cmd.Flags().StringVar(&updateServicePrincipalReq.ServicePrincipal.DisplayName, "display-name", updateServicePrincipalReq.ServicePrincipal.DisplayName, `Display name of the service principal.`) + cmd.Flags().StringVar(&updateServicePrincipalReq.ServicePrincipal.ExternalId, "external-id", updateServicePrincipalReq.ServicePrincipal.ExternalId, `ExternalId of the service principal in the customer's IdP.`) + + cmd.Use = "update-service-principal INTERNAL_ID UPDATE_MASK" + cmd.Short = `Update a service principal in the account.` + cmd.Long = `Update a service principal in the account. + + TODO: Write description later when this method is implemented + + Arguments: + INTERNAL_ID: Required. Internal ID of the service principal in Databricks. + UPDATE_MASK: Optional. The list of fields to update.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + if cmd.Flags().Changed("json") { + diags := updateServicePrincipalJson.Unmarshal(&updateServicePrincipalReq.ServicePrincipal) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + _, err = fmt.Sscan(args[0], &updateServicePrincipalReq.InternalId) + if err != nil { + return fmt.Errorf("invalid INTERNAL_ID: %s", args[0]) + } + updateServicePrincipalReq.UpdateMask = args[1] + + response, err := a.IamV2.UpdateServicePrincipal(ctx, updateServicePrincipalReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range updateServicePrincipalOverrides { + fn(cmd, &updateServicePrincipalReq) + } + + return cmd +} + +// start update-user command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var updateUserOverrides []func( + *cobra.Command, + *iamv2.UpdateUserRequest, +) + +func newUpdateUser() *cobra.Command { + cmd := &cobra.Command{} + + var updateUserReq iamv2.UpdateUserRequest + updateUserReq.User = iamv2.User{} + var updateUserJson flags.JsonFlag + + cmd.Flags().Var(&updateUserJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().Var(&updateUserReq.User.AccountUserStatus, "account-user-status", `The activity status of a user in a Databricks account. Supported values: [ACTIVE, INACTIVE]`) + cmd.Flags().StringVar(&updateUserReq.User.ExternalId, "external-id", updateUserReq.User.ExternalId, `ExternalId of the user in the customer's IdP.`) + // TODO: complex arg: name + + cmd.Use = "update-user INTERNAL_ID UPDATE_MASK USERNAME" + cmd.Short = `Update a user in the account.` + cmd.Long = `Update a user in the account. + + TODO: Write description later when this method is implemented + + Arguments: + INTERNAL_ID: Required. Internal ID of the user in Databricks. + UPDATE_MASK: Optional. The list of fields to update. + USERNAME: Username/email of the user.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + if cmd.Flags().Changed("json") { + err := root.ExactArgs(2)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, provide only INTERNAL_ID, UPDATE_MASK as positional arguments. Provide 'username' in your JSON input") + } + return nil + } + check := root.ExactArgs(3) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + if cmd.Flags().Changed("json") { + diags := updateUserJson.Unmarshal(&updateUserReq.User) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + _, err = fmt.Sscan(args[0], &updateUserReq.InternalId) + if err != nil { + return fmt.Errorf("invalid INTERNAL_ID: %s", args[0]) + } + updateUserReq.UpdateMask = args[1] + if !cmd.Flags().Changed("json") { + updateUserReq.User.Username = args[2] + } + + response, err := a.IamV2.UpdateUser(ctx, updateUserReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range updateUserOverrides { + fn(cmd, &updateUserReq) + } + + return cmd +} + +// start update-workspace-access-detail command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var updateWorkspaceAccessDetailOverrides []func( + *cobra.Command, + *iamv2.UpdateWorkspaceAccessDetailRequest, +) + +func newUpdateWorkspaceAccessDetail() *cobra.Command { + cmd := &cobra.Command{} + + var updateWorkspaceAccessDetailReq iamv2.UpdateWorkspaceAccessDetailRequest + updateWorkspaceAccessDetailReq.WorkspaceAccessDetail = iamv2.WorkspaceAccessDetail{} + var updateWorkspaceAccessDetailJson flags.JsonFlag + + cmd.Flags().Var(&updateWorkspaceAccessDetailJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + // TODO: array: permissions + cmd.Flags().Var(&updateWorkspaceAccessDetailReq.WorkspaceAccessDetail.Status, "status", `The activity status of the principal in the workspace. Supported values: [ACTIVE, INACTIVE]`) + + cmd.Use = "update-workspace-access-detail WORKSPACE_ID PRINCIPAL_ID UPDATE_MASK" + cmd.Short = `Update workspace access for a principal.` + cmd.Long = `Update workspace access for a principal. + + TODO: Write description later when this method is implemented + + Arguments: + WORKSPACE_ID: Required. The workspace ID for which the workspace access detail is being + updated. + PRINCIPAL_ID: Required. ID of the principal in Databricks. + UPDATE_MASK: Optional. The list of fields to update.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(3) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + if cmd.Flags().Changed("json") { + diags := updateWorkspaceAccessDetailJson.Unmarshal(&updateWorkspaceAccessDetailReq.WorkspaceAccessDetail) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + _, err = fmt.Sscan(args[0], &updateWorkspaceAccessDetailReq.WorkspaceId) + if err != nil { + return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) + } + _, err = fmt.Sscan(args[1], &updateWorkspaceAccessDetailReq.PrincipalId) + if err != nil { + return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[1]) + } + updateWorkspaceAccessDetailReq.UpdateMask = args[2] + + response, err := a.IamV2.UpdateWorkspaceAccessDetail(ctx, updateWorkspaceAccessDetailReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range updateWorkspaceAccessDetailOverrides { + fn(cmd, &updateWorkspaceAccessDetailReq) + } + + return cmd +} + // end service account_iamV2 diff --git a/cmd/account/metastore-assignments/metastore-assignments.go b/cmd/account/metastore-assignments/metastore-assignments.go index 9c45a876e8..86fcc37120 100755 --- a/cmd/account/metastore-assignments/metastore-assignments.go +++ b/cmd/account/metastore-assignments/metastore-assignments.go @@ -103,11 +103,11 @@ func newCreate() *cobra.Command { } createReq.MetastoreId = args[1] - err = a.MetastoreAssignments.Create(ctx, createReq) + response, err := a.MetastoreAssignments.Create(ctx, createReq) if err != nil { return err } - return nil + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -165,11 +165,11 @@ func newDelete() *cobra.Command { } deleteReq.MetastoreId = args[1] - err = a.MetastoreAssignments.Delete(ctx, deleteReq) + response, err := a.MetastoreAssignments.Delete(ctx, deleteReq) if err != nil { return err } - return nil + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -203,7 +203,7 @@ func newGet() *cobra.Command { cmd.Long = `Gets the metastore assignment for a workspace. Gets the metastore assignment, if any, for the workspace specified by ID. If - the workspace is assigned a metastore, the mappig will be returned. If no + the workspace is assigned a metastore, the mapping will be returned. If no metastore is assigned to the workspace, the assignment will not be found and a 404 returned. @@ -320,8 +320,8 @@ func newUpdate() *cobra.Command { // TODO: complex arg: metastore_assignment cmd.Use = "update WORKSPACE_ID METASTORE_ID" - cmd.Short = `Updates a metastore assignment to a workspaces.` - cmd.Long = `Updates a metastore assignment to a workspaces. + cmd.Short = `Updates a metastore assignment to a workspace.` + cmd.Long = `Updates a metastore assignment to a workspace. Updates an assignment to a metastore for a workspace. Currently, only the default catalog may be updated. @@ -360,11 +360,11 @@ func newUpdate() *cobra.Command { } updateReq.MetastoreId = args[1] - err = a.MetastoreAssignments.Update(ctx, updateReq) + response, err := a.MetastoreAssignments.Update(ctx, updateReq) if err != nil { return err } - return nil + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. diff --git a/cmd/account/metastores/metastores.go b/cmd/account/metastores/metastores.go index 6fa3ee645f..fe3aa6a6a1 100755 --- a/cmd/account/metastores/metastores.go +++ b/cmd/account/metastores/metastores.go @@ -63,8 +63,8 @@ func newCreate() *cobra.Command { // TODO: complex arg: metastore_info cmd.Use = "create" - cmd.Short = `Create metastore.` - cmd.Long = `Create metastore. + cmd.Short = `Create Metastore.` + cmd.Long = `Create Metastore. Creates a Unity Catalog metastore.` @@ -151,11 +151,11 @@ func newDelete() *cobra.Command { deleteReq.MetastoreId = args[0] - err = a.Metastores.Delete(ctx, deleteReq) + response, err := a.Metastores.Delete(ctx, deleteReq) if err != nil { return err } - return nil + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. diff --git a/cmd/account/network-connectivity/network-connectivity.go b/cmd/account/network-connectivity/network-connectivity.go index f7e3e66972..453d5b868d 100755 --- a/cmd/account/network-connectivity/network-connectivity.go +++ b/cmd/account/network-connectivity/network-connectivity.go @@ -177,6 +177,7 @@ func newCreatePrivateEndpointRule() *cobra.Command { // TODO: array: domain_names cmd.Flags().StringVar(&createPrivateEndpointRuleReq.PrivateEndpointRule.EndpointService, "endpoint-service", createPrivateEndpointRuleReq.PrivateEndpointRule.EndpointService, `The full target AWS endpoint service name that connects to the destination resources of the private endpoint.`) + // TODO: complex arg: gcp_endpoint_spec cmd.Flags().StringVar(&createPrivateEndpointRuleReq.PrivateEndpointRule.GroupId, "group-id", createPrivateEndpointRuleReq.PrivateEndpointRule.GroupId, `Not used by customer-managed private endpoint services.`) cmd.Flags().StringVar(&createPrivateEndpointRuleReq.PrivateEndpointRule.ResourceId, "resource-id", createPrivateEndpointRuleReq.PrivateEndpointRule.ResourceId, `The Azure resource ID of the target resource.`) // TODO: array: resource_names @@ -602,6 +603,7 @@ func newUpdatePrivateEndpointRule() *cobra.Command { // TODO: array: domain_names cmd.Flags().BoolVar(&updatePrivateEndpointRuleReq.PrivateEndpointRule.Enabled, "enabled", updatePrivateEndpointRuleReq.PrivateEndpointRule.Enabled, `Only used by private endpoints towards an AWS S3 service.`) + // TODO: complex arg: gcp_endpoint_spec // TODO: array: resource_names cmd.Use = "update-private-endpoint-rule NETWORK_CONNECTIVITY_CONFIG_ID PRIVATE_ENDPOINT_RULE_ID UPDATE_MASK" diff --git a/cmd/account/networks/networks.go b/cmd/account/networks/networks.go index 55b46e89a5..fc4c4bf586 100755 --- a/cmd/account/networks/networks.go +++ b/cmd/account/networks/networks.go @@ -3,8 +3,6 @@ package networks import ( - "fmt" - "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" @@ -62,33 +60,24 @@ func newCreate() *cobra.Command { cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: gcp_network_info + cmd.Flags().StringVar(&createReq.NetworkName, "network-name", createReq.NetworkName, `The human-readable name of the network configuration.`) // TODO: array: security_group_ids // TODO: array: subnet_ids // TODO: complex arg: vpc_endpoints - cmd.Flags().StringVar(&createReq.VpcId, "vpc-id", createReq.VpcId, `The ID of the VPC associated with this network.`) + cmd.Flags().StringVar(&createReq.VpcId, "vpc-id", createReq.VpcId, `The ID of the VPC associated with this network configuration.`) - cmd.Use = "create NETWORK_NAME" + cmd.Use = "create" cmd.Short = `Create network configuration.` cmd.Long = `Create network configuration. Creates a Databricks network configuration that represents an VPC and its resources. The VPC will be used for new Databricks clusters. This requires a - pre-existing VPC and subnets. - - Arguments: - NETWORK_NAME: The human-readable name of the network configuration.` + pre-existing VPC and subnets.` cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { - if cmd.Flags().Changed("json") { - err := root.ExactArgs(0)(cmd, args) - if err != nil { - return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'network_name' in your JSON input") - } - return nil - } - check := root.ExactArgs(1) + check := root.ExactArgs(0) return check(cmd, args) } @@ -109,9 +98,6 @@ func newCreate() *cobra.Command { } } } - if !cmd.Flags().Changed("json") { - createReq.NetworkName = args[0] - } response, err := a.Networks.Create(ctx, createReq) if err != nil { @@ -162,35 +148,23 @@ func newDelete() *cobra.Command { cmd.Annotations = make(map[string]string) + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) - if len(args) == 0 { - promptSpinner := cmdio.Spinner(ctx) - promptSpinner <- "No NETWORK_ID argument specified. Loading names for Networks drop-down." - names, err := a.Networks.NetworkNetworkNameToNetworkIdMap(ctx) - close(promptSpinner) - if err != nil { - return fmt.Errorf("failed to load names for Networks drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Databricks Account API network configuration ID") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have databricks account api network configuration id") - } deleteReq.NetworkId = args[0] - err = a.Networks.Delete(ctx, deleteReq) + response, err := a.Networks.Delete(ctx, deleteReq) if err != nil { return err } - return nil + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -231,28 +205,16 @@ func newGet() *cobra.Command { cmd.Annotations = make(map[string]string) + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) - if len(args) == 0 { - promptSpinner := cmdio.Spinner(ctx) - promptSpinner <- "No NETWORK_ID argument specified. Loading names for Networks drop-down." - names, err := a.Networks.NetworkNetworkNameToNetworkIdMap(ctx) - close(promptSpinner) - if err != nil { - return fmt.Errorf("failed to load names for Networks drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Databricks Account API network configuration ID") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have databricks account api network configuration id") - } getReq.NetworkId = args[0] response, err := a.Networks.Get(ctx, getReq) @@ -286,14 +248,10 @@ func newList() *cobra.Command { cmd := &cobra.Command{} cmd.Use = "list" - cmd.Short = `Get all network configurations.` - cmd.Long = `Get all network configurations. - - Gets a list of all Databricks network configurations for an account, specified - by ID. + cmd.Short = `List network configurations.` + cmd.Long = `List network configurations. - This operation is available only if your account is on the E2 version of the - platform.` + Lists Databricks network configurations for an account.` cmd.Annotations = make(map[string]string) diff --git a/cmd/account/private-access/private-access.go b/cmd/account/private-access/private-access.go index 486bf96ece..c054739604 100755 --- a/cmd/account/private-access/private-access.go +++ b/cmd/account/private-access/private-access.go @@ -3,8 +3,6 @@ package private_access import ( - "fmt" - "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" @@ -62,45 +60,24 @@ func newCreate() *cobra.Command { cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: allowed_vpc_endpoint_ids - cmd.Flags().Var(&createReq.PrivateAccessLevel, "private-access-level", `Supported values: [ACCOUNT, ENDPOINT]`) + cmd.Flags().Var(&createReq.PrivateAccessLevel, "private-access-level", `The private access level controls which VPC endpoints can connect to the UI or API of any workspace that attaches this private access settings object. Supported values: [ACCOUNT, ENDPOINT]`) + cmd.Flags().StringVar(&createReq.PrivateAccessSettingsName, "private-access-settings-name", createReq.PrivateAccessSettingsName, `The human-readable name of the private access settings object.`) cmd.Flags().BoolVar(&createReq.PublicAccessEnabled, "public-access-enabled", createReq.PublicAccessEnabled, `Determines if the workspace can be accessed over public internet.`) + cmd.Flags().StringVar(&createReq.Region, "region", createReq.Region, `The AWS region for workspaces attached to this private access settings object.`) - cmd.Use = "create PRIVATE_ACCESS_SETTINGS_NAME REGION" + cmd.Use = "create" cmd.Short = `Create private access settings.` cmd.Long = `Create private access settings. - Creates a private access settings object, which specifies how your workspace - is accessed over [AWS PrivateLink]. To use AWS PrivateLink, a workspace must - have a private access settings object referenced by ID in the workspace's - private_access_settings_id property. - - You can share one private access settings with multiple workspaces in a single - account. However, private access settings are specific to AWS regions, so only - workspaces in the same AWS region can use a given private access settings - object. - - Before configuring PrivateLink, read the [Databricks article about - PrivateLink]. - - [AWS PrivateLink]: https://aws.amazon.com/privatelink - [Databricks article about PrivateLink]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html - - Arguments: - PRIVATE_ACCESS_SETTINGS_NAME: The human-readable name of the private access settings object. - REGION: The cloud region for workspaces associated with this private access - settings object.` + Creates a private access settings configuration, which represents network + access restrictions for workspace resources. Private access settings configure + whether workspaces can be accessed from the public internet or only from + private endpoints.` cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { - if cmd.Flags().Changed("json") { - err := root.ExactArgs(0)(cmd, args) - if err != nil { - return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'private_access_settings_name', 'region' in your JSON input") - } - return nil - } - check := root.ExactArgs(2) + check := root.ExactArgs(0) return check(cmd, args) } @@ -121,12 +98,6 @@ func newCreate() *cobra.Command { } } } - if !cmd.Flags().Changed("json") { - createReq.PrivateAccessSettingsName = args[0] - } - if !cmd.Flags().Changed("json") { - createReq.Region = args[1] - } response, err := a.PrivateAccess.Create(ctx, createReq) if err != nil { @@ -162,52 +133,31 @@ func newDelete() *cobra.Command { var deleteReq provisioning.DeletePrivateAccesRequest cmd.Use = "delete PRIVATE_ACCESS_SETTINGS_ID" - cmd.Short = `Delete a private access settings object.` - cmd.Long = `Delete a private access settings object. - - Deletes a private access settings object, which determines how your workspace - is accessed over [AWS PrivateLink]. + cmd.Short = `Delete private access settings.` + cmd.Long = `Delete private access settings. - Before configuring PrivateLink, read the [Databricks article about - PrivateLink].", - - [AWS PrivateLink]: https://aws.amazon.com/privatelink - [Databricks article about PrivateLink]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html - - Arguments: - PRIVATE_ACCESS_SETTINGS_ID: Databricks Account API private access settings ID.` + Deletes a Databricks private access settings configuration, both specified by + ID.` cmd.Annotations = make(map[string]string) + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) - if len(args) == 0 { - promptSpinner := cmdio.Spinner(ctx) - promptSpinner <- "No PRIVATE_ACCESS_SETTINGS_ID argument specified. Loading names for Private Access drop-down." - names, err := a.PrivateAccess.PrivateAccessSettingsPrivateAccessSettingsNameToPrivateAccessSettingsIdMap(ctx) - close(promptSpinner) - if err != nil { - return fmt.Errorf("failed to load names for Private Access drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Databricks Account API private access settings ID") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have databricks account api private access settings id") - } deleteReq.PrivateAccessSettingsId = args[0] - err = a.PrivateAccess.Delete(ctx, deleteReq) + response, err := a.PrivateAccess.Delete(ctx, deleteReq) if err != nil { return err } - return nil + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -237,45 +187,23 @@ func newGet() *cobra.Command { var getReq provisioning.GetPrivateAccesRequest cmd.Use = "get PRIVATE_ACCESS_SETTINGS_ID" - cmd.Short = `Get a private access settings object.` - cmd.Long = `Get a private access settings object. + cmd.Short = `Get private access settings.` + cmd.Long = `Get private access settings. - Gets a private access settings object, which specifies how your workspace is - accessed over [AWS PrivateLink]. - - Before configuring PrivateLink, read the [Databricks article about - PrivateLink].", - - [AWS PrivateLink]: https://aws.amazon.com/privatelink - [Databricks article about PrivateLink]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html - - Arguments: - PRIVATE_ACCESS_SETTINGS_ID: Databricks Account API private access settings ID.` + Gets a Databricks private access settings configuration, both specified by ID.` cmd.Annotations = make(map[string]string) + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) - if len(args) == 0 { - promptSpinner := cmdio.Spinner(ctx) - promptSpinner <- "No PRIVATE_ACCESS_SETTINGS_ID argument specified. Loading names for Private Access drop-down." - names, err := a.PrivateAccess.PrivateAccessSettingsPrivateAccessSettingsNameToPrivateAccessSettingsIdMap(ctx) - close(promptSpinner) - if err != nil { - return fmt.Errorf("failed to load names for Private Access drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Databricks Account API private access settings ID") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have databricks account api private access settings id") - } getReq.PrivateAccessSettingsId = args[0] response, err := a.PrivateAccess.Get(ctx, getReq) @@ -309,11 +237,10 @@ func newList() *cobra.Command { cmd := &cobra.Command{} cmd.Use = "list" - cmd.Short = `Get all private access settings objects.` - cmd.Long = `Get all private access settings objects. + cmd.Short = `List private access settings.` + cmd.Long = `List private access settings. - Gets a list of all private access settings objects for an account, specified - by ID.` + Lists Databricks private access settings for an account.` cmd.Annotations = make(map[string]string) @@ -353,57 +280,42 @@ func newReplace() *cobra.Command { cmd := &cobra.Command{} var replaceReq provisioning.ReplacePrivateAccessSettingsRequest + replaceReq.CustomerFacingPrivateAccessSettings = provisioning.PrivateAccessSettings{} var replaceJson flags.JsonFlag cmd.Flags().Var(&replaceJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: allowed_vpc_endpoint_ids - cmd.Flags().Var(&replaceReq.PrivateAccessLevel, "private-access-level", `Supported values: [ACCOUNT, ENDPOINT]`) - cmd.Flags().BoolVar(&replaceReq.PublicAccessEnabled, "public-access-enabled", replaceReq.PublicAccessEnabled, `Determines if the workspace can be accessed over public internet.`) - - cmd.Use = "replace PRIVATE_ACCESS_SETTINGS_ID PRIVATE_ACCESS_SETTINGS_NAME REGION" - cmd.Short = `Replace private access settings.` - cmd.Long = `Replace private access settings. + cmd.Flags().Var(&replaceReq.CustomerFacingPrivateAccessSettings.PrivateAccessLevel, "private-access-level", `The private access level controls which VPC endpoints can connect to the UI or API of any workspace that attaches this private access settings object. Supported values: [ACCOUNT, ENDPOINT]`) + cmd.Flags().StringVar(&replaceReq.CustomerFacingPrivateAccessSettings.PrivateAccessSettingsName, "private-access-settings-name", replaceReq.CustomerFacingPrivateAccessSettings.PrivateAccessSettingsName, `The human-readable name of the private access settings object.`) + cmd.Flags().BoolVar(&replaceReq.CustomerFacingPrivateAccessSettings.PublicAccessEnabled, "public-access-enabled", replaceReq.CustomerFacingPrivateAccessSettings.PublicAccessEnabled, `Determines if the workspace can be accessed over public internet.`) + cmd.Flags().StringVar(&replaceReq.CustomerFacingPrivateAccessSettings.Region, "region", replaceReq.CustomerFacingPrivateAccessSettings.Region, `The AWS region for workspaces attached to this private access settings object.`) + + cmd.Use = "replace PRIVATE_ACCESS_SETTINGS_ID" + cmd.Short = `Update private access settings.` + cmd.Long = `Update private access settings. Updates an existing private access settings object, which specifies how your - workspace is accessed over [AWS PrivateLink]. To use AWS PrivateLink, a + workspace is accessed over AWS PrivateLink. To use AWS PrivateLink, a workspace must have a private access settings object referenced by ID in the - workspace's private_access_settings_id property. - - This operation completely overwrites your existing private access settings - object attached to your workspaces. All workspaces attached to the private - access settings are affected by any change. If public_access_enabled, - private_access_level, or allowed_vpc_endpoint_ids are updated, effects of - these changes might take several minutes to propagate to the workspace API. - - You can share one private access settings object with multiple workspaces in a - single account. However, private access settings are specific to AWS regions, - so only workspaces in the same AWS region can use a given private access - settings object. - - Before configuring PrivateLink, read the [Databricks article about - PrivateLink]. - - [AWS PrivateLink]: https://aws.amazon.com/privatelink - [Databricks article about PrivateLink]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html + workspace's private_access_settings_id property. This operation completely + overwrites your existing private access settings object attached to your + workspaces. All workspaces attached to the private access settings are + affected by any change. If public_access_enabled, private_access_level, or + allowed_vpc_endpoint_ids are updated, effects of these changes might take + several minutes to propagate to the workspace API. You can share one private + access settings object with multiple workspaces in a single account. However, + private access settings are specific to AWS regions, so only workspaces in the + same AWS region can use a given private access settings object. Before + configuring PrivateLink, read the Databricks article about PrivateLink. Arguments: - PRIVATE_ACCESS_SETTINGS_ID: Databricks Account API private access settings ID. - PRIVATE_ACCESS_SETTINGS_NAME: The human-readable name of the private access settings object. - REGION: The cloud region for workspaces associated with this private access - settings object.` + PRIVATE_ACCESS_SETTINGS_ID: Databricks private access settings ID.` cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { - if cmd.Flags().Changed("json") { - err := root.ExactArgs(1)(cmd, args) - if err != nil { - return fmt.Errorf("when --json flag is specified, provide only PRIVATE_ACCESS_SETTINGS_ID as positional arguments. Provide 'private_access_settings_name', 'region' in your JSON input") - } - return nil - } - check := root.ExactArgs(3) + check := root.ExactArgs(1) return check(cmd, args) } @@ -413,7 +325,7 @@ func newReplace() *cobra.Command { a := cmdctx.AccountClient(ctx) if cmd.Flags().Changed("json") { - diags := replaceJson.Unmarshal(&replaceReq) + diags := replaceJson.Unmarshal(&replaceReq.CustomerFacingPrivateAccessSettings) if diags.HasError() { return diags.Error() } @@ -425,18 +337,12 @@ func newReplace() *cobra.Command { } } replaceReq.PrivateAccessSettingsId = args[0] - if !cmd.Flags().Changed("json") { - replaceReq.PrivateAccessSettingsName = args[1] - } - if !cmd.Flags().Changed("json") { - replaceReq.Region = args[2] - } - err = a.PrivateAccess.Replace(ctx, replaceReq) + response, err := a.PrivateAccess.Replace(ctx, replaceReq) if err != nil { return err } - return nil + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. diff --git a/cmd/account/storage-credentials/storage-credentials.go b/cmd/account/storage-credentials/storage-credentials.go index c1b5d01ef3..c2229d378d 100755 --- a/cmd/account/storage-credentials/storage-credentials.go +++ b/cmd/account/storage-credentials/storage-credentials.go @@ -60,18 +60,18 @@ func newCreate() *cobra.Command { cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: credential_info + cmd.Flags().BoolVar(&createReq.SkipValidation, "skip-validation", createReq.SkipValidation, `Optional, default false.`) cmd.Use = "create METASTORE_ID" cmd.Short = `Create a storage credential.` cmd.Long = `Create a storage credential. Creates a new storage credential. The request object is specific to the cloud: + - **AwsIamRole** for AWS credentials - **AzureServicePrincipal** for Azure + credentials - **GcpServiceAccountKey** for GCP credentials - * **AwsIamRole** for AWS credentials * **AzureServicePrincipal** for Azure - credentials * **GcpServiceAcountKey** for GCP credentials. - - The caller must be a metastore admin and have the - **CREATE_STORAGE_CREDENTIAL** privilege on the metastore. + The caller must be a metastore admin and have the CREATE_STORAGE_CREDENTIAL + privilege on the metastore. Arguments: METASTORE_ID: Unity Catalog metastore ID` @@ -163,11 +163,11 @@ func newDelete() *cobra.Command { deleteReq.MetastoreId = args[0] deleteReq.StorageCredentialName = args[1] - err = a.StorageCredentials.Delete(ctx, deleteReq) + response, err := a.StorageCredentials.Delete(ctx, deleteReq) if err != nil { return err } - return nil + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -206,7 +206,7 @@ func newGet() *cobra.Command { Arguments: METASTORE_ID: Unity Catalog metastore ID - STORAGE_CREDENTIAL_NAME: Name of the storage credential.` + STORAGE_CREDENTIAL_NAME: Required. Name of the storage credential.` cmd.Annotations = make(map[string]string) @@ -314,13 +314,14 @@ func newUpdate() *cobra.Command { cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: credential_info + cmd.Flags().BoolVar(&updateReq.SkipValidation, "skip-validation", updateReq.SkipValidation, `Optional.`) cmd.Use = "update METASTORE_ID STORAGE_CREDENTIAL_NAME" cmd.Short = `Updates a storage credential.` cmd.Long = `Updates a storage credential. Updates a storage credential on the metastore. The caller must be the owner of - the storage credential. If the caller is a metastore admin, only the __owner__ + the storage credential. If the caller is a metastore admin, only the **owner** credential can be changed. Arguments: diff --git a/cmd/account/storage/storage.go b/cmd/account/storage/storage.go index eaca50e904..96f4cf9e6b 100755 --- a/cmd/account/storage/storage.go +++ b/cmd/account/storage/storage.go @@ -65,20 +65,13 @@ func newCreate() *cobra.Command { cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) + cmd.Flags().StringVar(&createReq.RoleArn, "role-arn", createReq.RoleArn, `Optional IAM role that is used to access the workspace catalog which is created during workspace creation for UC by Default.`) + cmd.Use = "create" - cmd.Short = `Create new storage configuration.` - cmd.Long = `Create new storage configuration. - - Creates new storage configuration for an account, specified by ID. Uploads a - storage configuration object that represents the root AWS S3 bucket in your - account. Databricks stores related workspace assets including DBFS, cluster - logs, and job results. For the AWS S3 bucket, you need to configure the - required bucket policy. - - For information about how to create a new workspace with this API, see [Create - a new workspace using the Account API] + cmd.Short = `Create a storage configuration.` + cmd.Long = `Create a storage configuration. - [Create a new workspace using the Account API]: http://docs.databricks.com/administration-guide/account-api/new-workspace.html` + Creates a Databricks storage configuration for an account.` cmd.Annotations = make(map[string]string) @@ -136,46 +129,31 @@ func newDelete() *cobra.Command { var deleteReq provisioning.DeleteStorageRequest cmd.Use = "delete STORAGE_CONFIGURATION_ID" - cmd.Short = `Delete storage configuration.` - cmd.Long = `Delete storage configuration. + cmd.Short = `Delete a storage configuration.` + cmd.Long = `Delete a storage configuration. Deletes a Databricks storage configuration. You cannot delete a storage - configuration that is associated with any workspace. - - Arguments: - STORAGE_CONFIGURATION_ID: Databricks Account API storage configuration ID.` + configuration that is associated with any workspace.` cmd.Annotations = make(map[string]string) + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) - if len(args) == 0 { - promptSpinner := cmdio.Spinner(ctx) - promptSpinner <- "No STORAGE_CONFIGURATION_ID argument specified. Loading names for Storage drop-down." - names, err := a.Storage.StorageConfigurationStorageConfigurationNameToStorageConfigurationIdMap(ctx) - close(promptSpinner) - if err != nil { - return fmt.Errorf("failed to load names for Storage drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Databricks Account API storage configuration ID") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have databricks account api storage configuration id") - } deleteReq.StorageConfigurationId = args[0] - err = a.Storage.Delete(ctx, deleteReq) + response, err := a.Storage.Delete(ctx, deleteReq) if err != nil { return err } - return nil + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -205,38 +183,23 @@ func newGet() *cobra.Command { var getReq provisioning.GetStorageRequest cmd.Use = "get STORAGE_CONFIGURATION_ID" - cmd.Short = `Get storage configuration.` - cmd.Long = `Get storage configuration. + cmd.Short = `Get a storage configuration.` + cmd.Long = `Get a storage configuration. - Gets a Databricks storage configuration for an account, both specified by ID. - - Arguments: - STORAGE_CONFIGURATION_ID: Databricks Account API storage configuration ID.` + Gets a Databricks storage configuration for an account, both specified by ID.` cmd.Annotations = make(map[string]string) + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) - if len(args) == 0 { - promptSpinner := cmdio.Spinner(ctx) - promptSpinner <- "No STORAGE_CONFIGURATION_ID argument specified. Loading names for Storage drop-down." - names, err := a.Storage.StorageConfigurationStorageConfigurationNameToStorageConfigurationIdMap(ctx) - close(promptSpinner) - if err != nil { - return fmt.Errorf("failed to load names for Storage drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Databricks Account API storage configuration ID") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have databricks account api storage configuration id") - } getReq.StorageConfigurationId = args[0] response, err := a.Storage.Get(ctx, getReq) @@ -270,11 +233,10 @@ func newList() *cobra.Command { cmd := &cobra.Command{} cmd.Use = "list" - cmd.Short = `Get all storage configurations.` - cmd.Long = `Get all storage configurations. + cmd.Short = `List storage configurations.` + cmd.Long = `List storage configurations. - Gets a list of all Databricks storage configurations for your account, - specified by ID.` + Lists Databricks storage configurations for an account, specified by ID.` cmd.Annotations = make(map[string]string) diff --git a/cmd/account/usage-policy/usage-policy.go b/cmd/account/usage-policy/usage-policy.go new file mode 100755 index 0000000000..538cd09a26 --- /dev/null +++ b/cmd/account/usage-policy/usage-policy.go @@ -0,0 +1,362 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package usage_policy + +import ( + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/flags" + "github.com/databricks/databricks-sdk-go/service/billing" + "github.com/spf13/cobra" +) + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var cmdOverrides []func(*cobra.Command) + +func New() *cobra.Command { + cmd := &cobra.Command{ + Use: "usage-policy", + Short: `A service serves REST API about Usage policies.`, + Long: `A service serves REST API about Usage policies`, + GroupID: "billing", + Annotations: map[string]string{ + "package": "billing", + }, + + // This service is being previewed; hide from help output. + Hidden: true, + RunE: root.ReportUnknownSubcommand, + } + + // Add methods + cmd.AddCommand(newCreate()) + cmd.AddCommand(newDelete()) + cmd.AddCommand(newGet()) + cmd.AddCommand(newList()) + cmd.AddCommand(newUpdate()) + + // Apply optional overrides to this command. + for _, fn := range cmdOverrides { + fn(cmd) + } + + return cmd +} + +// start create command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var createOverrides []func( + *cobra.Command, + *billing.CreateUsagePolicyRequest, +) + +func newCreate() *cobra.Command { + cmd := &cobra.Command{} + + var createReq billing.CreateUsagePolicyRequest + var createJson flags.JsonFlag + + cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + // TODO: complex arg: policy + cmd.Flags().StringVar(&createReq.RequestId, "request-id", createReq.RequestId, `A unique identifier for this request.`) + + cmd.Use = "create" + cmd.Short = `Create a usage policy.` + cmd.Long = `Create a usage policy. + + Creates a new usage policy.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(0) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + if cmd.Flags().Changed("json") { + diags := createJson.Unmarshal(&createReq) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + + response, err := a.UsagePolicy.Create(ctx, createReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range createOverrides { + fn(cmd, &createReq) + } + + return cmd +} + +// start delete command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var deleteOverrides []func( + *cobra.Command, + *billing.DeleteUsagePolicyRequest, +) + +func newDelete() *cobra.Command { + cmd := &cobra.Command{} + + var deleteReq billing.DeleteUsagePolicyRequest + + cmd.Use = "delete POLICY_ID" + cmd.Short = `Delete a usage policy.` + cmd.Long = `Delete a usage policy. + + Deletes a usage policy + + Arguments: + POLICY_ID: The Id of the policy.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + deleteReq.PolicyId = args[0] + + err = a.UsagePolicy.Delete(ctx, deleteReq) + if err != nil { + return err + } + return nil + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range deleteOverrides { + fn(cmd, &deleteReq) + } + + return cmd +} + +// start get command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var getOverrides []func( + *cobra.Command, + *billing.GetUsagePolicyRequest, +) + +func newGet() *cobra.Command { + cmd := &cobra.Command{} + + var getReq billing.GetUsagePolicyRequest + + cmd.Use = "get POLICY_ID" + cmd.Short = `Get a usage policy.` + cmd.Long = `Get a usage policy. + + Retrieves a usage policy by it's ID. + + Arguments: + POLICY_ID: The Id of the policy.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + getReq.PolicyId = args[0] + + response, err := a.UsagePolicy.Get(ctx, getReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range getOverrides { + fn(cmd, &getReq) + } + + return cmd +} + +// start list command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var listOverrides []func( + *cobra.Command, + *billing.ListUsagePoliciesRequest, +) + +func newList() *cobra.Command { + cmd := &cobra.Command{} + + var listReq billing.ListUsagePoliciesRequest + + // TODO: complex arg: filter_by + cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, `The maximum number of usage policies to return.`) + cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `A page token, received from a previous ListUsagePolicies call.`) + // TODO: complex arg: sort_spec + + cmd.Use = "list" + cmd.Short = `List usage policies.` + cmd.Long = `List usage policies. + + Lists all usage policies. Policies are returned in the alphabetically + ascending order of their names.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(0) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + response := a.UsagePolicy.List(ctx, listReq) + return cmdio.RenderIterator(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range listOverrides { + fn(cmd, &listReq) + } + + return cmd +} + +// start update command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var updateOverrides []func( + *cobra.Command, + *billing.UpdateUsagePolicyRequest, +) + +func newUpdate() *cobra.Command { + cmd := &cobra.Command{} + + var updateReq billing.UpdateUsagePolicyRequest + updateReq.Policy = billing.UsagePolicy{} + var updateJson flags.JsonFlag + + cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + // TODO: complex arg: limit_config + // TODO: array: binding_workspace_ids + // TODO: array: custom_tags + cmd.Flags().StringVar(&updateReq.Policy.PolicyName, "policy-name", updateReq.Policy.PolicyName, `The name of the policy.`) + + cmd.Use = "update POLICY_ID" + cmd.Short = `Update a usage policy.` + cmd.Long = `Update a usage policy. + + Updates a usage policy + + Arguments: + POLICY_ID: The Id of the policy. This field is generated by Databricks and globally + unique.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustAccountClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + a := cmdctx.AccountClient(ctx) + + if cmd.Flags().Changed("json") { + diags := updateJson.Unmarshal(&updateReq.Policy) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + updateReq.PolicyId = args[0] + + response, err := a.UsagePolicy.Update(ctx, updateReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range updateOverrides { + fn(cmd, &updateReq) + } + + return cmd +} + +// end service UsagePolicy diff --git a/cmd/account/vpc-endpoints/vpc-endpoints.go b/cmd/account/vpc-endpoints/vpc-endpoints.go index fdd1e506f1..69a771f588 100755 --- a/cmd/account/vpc-endpoints/vpc-endpoints.go +++ b/cmd/account/vpc-endpoints/vpc-endpoints.go @@ -3,8 +3,6 @@ package vpc_endpoints import ( - "fmt" - "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" @@ -62,11 +60,12 @@ func newCreate() *cobra.Command { cmd.Flags().StringVar(&createReq.AwsVpcEndpointId, "aws-vpc-endpoint-id", createReq.AwsVpcEndpointId, `The ID of the VPC endpoint object in AWS.`) // TODO: complex arg: gcp_vpc_endpoint_info - cmd.Flags().StringVar(&createReq.Region, "region", createReq.Region, `The AWS region in which this VPC endpoint object exists.`) + cmd.Flags().StringVar(&createReq.Region, "region", createReq.Region, `The region in which this VPC endpoint object exists.`) + cmd.Flags().StringVar(&createReq.VpcEndpointName, "vpc-endpoint-name", createReq.VpcEndpointName, `The human-readable name of the storage configuration.`) - cmd.Use = "create VPC_ENDPOINT_NAME" - cmd.Short = `Create VPC endpoint configuration.` - cmd.Long = `Create VPC endpoint configuration. + cmd.Use = "create" + cmd.Short = `Create a VPC endpoint configuration.` + cmd.Long = `Create a VPC endpoint configuration. Creates a VPC endpoint configuration, which represents a [VPC endpoint] object in AWS used to communicate privately with Databricks over [AWS PrivateLink]. @@ -80,22 +79,12 @@ func newCreate() *cobra.Command { [AWS PrivateLink]: https://aws.amazon.com/privatelink [Databricks article about PrivateLink]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html [VPC endpoint]: https://docs.aws.amazon.com/vpc/latest/privatelink/vpc-endpoints.html - [endpoint service]: https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-share-your-services.html - - Arguments: - VPC_ENDPOINT_NAME: The human-readable name of the storage configuration.` + [endpoint service]: https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-share-your-services.html` cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { - if cmd.Flags().Changed("json") { - err := root.ExactArgs(0)(cmd, args) - if err != nil { - return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'vpc_endpoint_name' in your JSON input") - } - return nil - } - check := root.ExactArgs(1) + check := root.ExactArgs(0) return check(cmd, args) } @@ -116,9 +105,6 @@ func newCreate() *cobra.Command { } } } - if !cmd.Flags().Changed("json") { - createReq.VpcEndpointName = args[0] - } response, err := a.VpcEndpoints.Create(ctx, createReq) if err != nil { @@ -154,53 +140,31 @@ func newDelete() *cobra.Command { var deleteReq provisioning.DeleteVpcEndpointRequest cmd.Use = "delete VPC_ENDPOINT_ID" - cmd.Short = `Delete VPC endpoint configuration.` - cmd.Long = `Delete VPC endpoint configuration. - - Deletes a VPC endpoint configuration, which represents an [AWS VPC endpoint] - that can communicate privately with Databricks over [AWS PrivateLink]. - - Before configuring PrivateLink, read the [Databricks article about - PrivateLink]. + cmd.Short = `Delete a VPC endpoint configuration.` + cmd.Long = `Delete a VPC endpoint configuration. - [AWS PrivateLink]: https://aws.amazon.com/privatelink - [AWS VPC endpoint]: https://docs.aws.amazon.com/vpc/latest/privatelink/concepts.html - [Databricks article about PrivateLink]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html - - Arguments: - VPC_ENDPOINT_ID: Databricks VPC endpoint ID.` + Deletes a Databricks VPC endpoint configuration. You cannot delete a VPC + endpoint configuration that is associated with any workspace.` cmd.Annotations = make(map[string]string) + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) - if len(args) == 0 { - promptSpinner := cmdio.Spinner(ctx) - promptSpinner <- "No VPC_ENDPOINT_ID argument specified. Loading names for Vpc Endpoints drop-down." - names, err := a.VpcEndpoints.VpcEndpointVpcEndpointNameToVpcEndpointIdMap(ctx) - close(promptSpinner) - if err != nil { - return fmt.Errorf("failed to load names for Vpc Endpoints drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Databricks VPC endpoint ID") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have databricks vpc endpoint id") - } deleteReq.VpcEndpointId = args[0] - err = a.VpcEndpoints.Delete(ctx, deleteReq) + response, err := a.VpcEndpoints.Delete(ctx, deleteReq) if err != nil { return err } - return nil + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -244,28 +208,16 @@ func newGet() *cobra.Command { cmd.Annotations = make(map[string]string) + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) - if len(args) == 0 { - promptSpinner := cmdio.Spinner(ctx) - promptSpinner <- "No VPC_ENDPOINT_ID argument specified. Loading names for Vpc Endpoints drop-down." - names, err := a.VpcEndpoints.VpcEndpointVpcEndpointNameToVpcEndpointIdMap(ctx) - close(promptSpinner) - if err != nil { - return fmt.Errorf("failed to load names for Vpc Endpoints drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Databricks VPC endpoint ID") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have databricks vpc endpoint id") - } getReq.VpcEndpointId = args[0] response, err := a.VpcEndpoints.Get(ctx, getReq) @@ -299,15 +251,10 @@ func newList() *cobra.Command { cmd := &cobra.Command{} cmd.Use = "list" - cmd.Short = `Get all VPC endpoint configurations.` - cmd.Long = `Get all VPC endpoint configurations. - - Gets a list of all VPC endpoints for an account, specified by ID. - - Before configuring PrivateLink, read the [Databricks article about - PrivateLink]. + cmd.Short = `List VPC endpoint configurations.` + cmd.Long = `List VPC endpoint configurations. - [Databricks article about PrivateLink]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html` + Lists Databricks VPC endpoint configurations for an account.` cmd.Annotations = make(map[string]string) diff --git a/cmd/account/workspaces/workspaces.go b/cmd/account/workspaces/workspaces.go index 97641f3af4..7c922b10ca 100755 --- a/cmd/account/workspaces/workspaces.go +++ b/cmd/account/workspaces/workspaces.go @@ -75,18 +75,17 @@ func newCreate() *cobra.Command { cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createReq.AwsRegion, "aws-region", createReq.AwsRegion, `The AWS region of the workspace's data plane.`) - cmd.Flags().StringVar(&createReq.Cloud, "cloud", createReq.Cloud, `The cloud provider which the workspace uses.`) + cmd.Flags().StringVar(&createReq.AwsRegion, "aws-region", createReq.AwsRegion, ``) + cmd.Flags().StringVar(&createReq.Cloud, "cloud", createReq.Cloud, `The cloud name.`) // TODO: complex arg: cloud_resource_container cmd.Flags().StringVar(&createReq.CredentialsId, "credentials-id", createReq.CredentialsId, `ID of the workspace's credential configuration object.`) // TODO: map via StringToStringVar: custom_tags cmd.Flags().StringVar(&createReq.DeploymentName, "deployment-name", createReq.DeploymentName, `The deployment name defines part of the subdomain for the workspace.`) // TODO: complex arg: gcp_managed_network_config // TODO: complex arg: gke_config - cmd.Flags().BoolVar(&createReq.IsNoPublicIpEnabled, "is-no-public-ip-enabled", createReq.IsNoPublicIpEnabled, `Whether no public IP is enabled for the workspace.`) - cmd.Flags().StringVar(&createReq.Location, "location", createReq.Location, `The Google Cloud region of the workspace data plane in your Google account.`) + cmd.Flags().StringVar(&createReq.Location, "location", createReq.Location, `The Google Cloud region of the workspace data plane in your Google account (for example, us-east4).`) cmd.Flags().StringVar(&createReq.ManagedServicesCustomerManagedKeyId, "managed-services-customer-managed-key-id", createReq.ManagedServicesCustomerManagedKeyId, `The ID of the workspace's managed services encryption key configuration object.`) - cmd.Flags().StringVar(&createReq.NetworkId, "network-id", createReq.NetworkId, ``) + cmd.Flags().StringVar(&createReq.NetworkId, "network-id", createReq.NetworkId, `The ID of the workspace's network configuration object.`) cmd.Flags().Var(&createReq.PricingTier, "pricing-tier", `Supported values: [ COMMUNITY_EDITION, DEDICATED, @@ -96,37 +95,55 @@ func newCreate() *cobra.Command { UNKNOWN, ]`) cmd.Flags().StringVar(&createReq.PrivateAccessSettingsId, "private-access-settings-id", createReq.PrivateAccessSettingsId, `ID of the workspace's private access settings object.`) - cmd.Flags().StringVar(&createReq.StorageConfigurationId, "storage-configuration-id", createReq.StorageConfigurationId, `The ID of the workspace's storage configuration object.`) + cmd.Flags().StringVar(&createReq.StorageConfigurationId, "storage-configuration-id", createReq.StorageConfigurationId, `ID of the workspace's storage configuration object.`) cmd.Flags().StringVar(&createReq.StorageCustomerManagedKeyId, "storage-customer-managed-key-id", createReq.StorageCustomerManagedKeyId, `The ID of the workspace's storage encryption key configuration object.`) + cmd.Flags().StringVar(&createReq.WorkspaceName, "workspace-name", createReq.WorkspaceName, `The human-readable name of the workspace.`) - cmd.Use = "create WORKSPACE_NAME" - cmd.Short = `Create a new workspace.` - cmd.Long = `Create a new workspace. + cmd.Use = "create" + cmd.Short = `Create a workspace.` + cmd.Long = `Create a workspace. - Creates a new workspace. + Creates a new workspace using a credential configuration and a storage + configuration, an optional network configuration (if using a customer-managed + VPC), an optional managed services key configuration (if using + customer-managed keys for managed services), and an optional storage key + configuration (if using customer-managed keys for storage). The key + configurations used for managed services and storage encryption can be the + same or different. - **Important**: This operation is asynchronous. A response with HTTP status - code 200 means the request has been accepted and is in progress, but does not - mean that the workspace deployed successfully and is running. The initial - workspace status is typically PROVISIONING. Use the workspace ID - (workspace_id) field in the response to identify the new workspace and make - repeated GET requests with the workspace ID and check its status. The - workspace becomes available when the status changes to RUNNING. - - Arguments: - WORKSPACE_NAME: The workspace's human-readable name.` + Important: This operation is asynchronous. A response with HTTP status code + 200 means the request has been accepted and is in progress, but does not mean + that the workspace deployed successfully and is running. The initial workspace + status is typically PROVISIONING. Use the workspace ID (workspace_id) field in + the response to identify the new workspace and make repeated GET requests with + the workspace ID and check its status. The workspace becomes available when + the status changes to RUNNING. + + You can share one customer-managed VPC with multiple workspaces in a single + account. It is not required to create a new VPC for each workspace. However, + you cannot reuse subnets or Security Groups between workspaces. If you plan to + share one VPC with multiple workspaces, make sure you size your VPC and + subnets accordingly. Because a Databricks Account API network configuration + encapsulates this information, you cannot reuse a Databricks Account API + network configuration across workspaces. + + For information about how to create a new workspace with this API including + error handling, see [Create a new workspace using the Account API]. + + Important: Customer-managed VPCs, PrivateLink, and customer-managed keys are + supported on a limited set of deployment and subscription types. If you have + questions about availability, contact your Databricks representative. + + This operation is available only if your account is on the E2 version of the + platform or on a select custom plan that allows multiple workspaces per + account. + + [Create a new workspace using the Account API]: http://docs.databricks.com/administration-guide/account-api/new-workspace.html` cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { - if cmd.Flags().Changed("json") { - err := root.ExactArgs(0)(cmd, args) - if err != nil { - return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'workspace_name' in your JSON input") - } - return nil - } - check := root.ExactArgs(1) + check := root.ExactArgs(0) return check(cmd, args) } @@ -147,9 +164,6 @@ func newCreate() *cobra.Command { } } } - if !cmd.Flags().Changed("json") { - createReq.WorkspaceName = args[0] - } wait, err := a.Workspaces.Create(ctx, createReq) if err != nil { @@ -200,52 +214,30 @@ func newDelete() *cobra.Command { cmd.Short = `Delete a workspace.` cmd.Long = `Delete a workspace. - Terminates and deletes a Databricks workspace. From an API perspective, - deletion is immediate. However, it might take a few minutes for all workspaces - resources to be deleted, depending on the size and number of workspace - resources. - - This operation is available only if your account is on the E2 version of the - platform or on a select custom plan that allows multiple workspaces per - account. - - Arguments: - WORKSPACE_ID: Workspace ID.` + Deletes a Databricks workspace, both specified by ID.` cmd.Annotations = make(map[string]string) + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) - if len(args) == 0 { - promptSpinner := cmdio.Spinner(ctx) - promptSpinner <- "No WORKSPACE_ID argument specified. Loading names for Workspaces drop-down." - names, err := a.Workspaces.WorkspaceWorkspaceNameToWorkspaceIdMap(ctx) - close(promptSpinner) - if err != nil { - return fmt.Errorf("failed to load names for Workspaces drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Workspace ID") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have workspace id") - } _, err = fmt.Sscan(args[0], &deleteReq.WorkspaceId) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } - err = a.Workspaces.Delete(ctx, deleteReq) + response, err := a.Workspaces.Delete(ctx, deleteReq) if err != nil { return err } - return nil + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -282,44 +274,24 @@ func newGet() *cobra.Command { In the response, the workspace_status field indicates the current status. After initial workspace creation (which is asynchronous), make repeated GET requests with the workspace ID and check its status. The workspace becomes - available when the status changes to RUNNING. - - For information about how to create a new workspace with this API **including - error handling**, see [Create a new workspace using the Account API]. + available when the status changes to RUNNING. For information about how to + create a new workspace with this API **including error handling**, see [Create + a new workspace using the Account API]. - This operation is available only if your account is on the E2 version of the - platform or on a select custom plan that allows multiple workspaces per - account. - - [Create a new workspace using the Account API]: http://docs.databricks.com/administration-guide/account-api/new-workspace.html - - Arguments: - WORKSPACE_ID: Workspace ID.` + [Create a new workspace using the Account API]: http://docs.databricks.com/administration-guide/account-api/new-workspace.html` cmd.Annotations = make(map[string]string) + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) - if len(args) == 0 { - promptSpinner := cmdio.Spinner(ctx) - promptSpinner <- "No WORKSPACE_ID argument specified. Loading names for Workspaces drop-down." - names, err := a.Workspaces.WorkspaceWorkspaceNameToWorkspaceIdMap(ctx) - close(promptSpinner) - if err != nil { - return fmt.Errorf("failed to load names for Workspaces drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Workspace ID") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have workspace id") - } _, err = fmt.Sscan(args[0], &getReq.WorkspaceId) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) @@ -356,14 +328,10 @@ func newList() *cobra.Command { cmd := &cobra.Command{} cmd.Use = "list" - cmd.Short = `Get all workspaces.` - cmd.Long = `Get all workspaces. - - Gets a list of all workspaces associated with an account, specified by ID. + cmd.Short = `List workspaces.` + cmd.Long = `List workspaces. - This operation is available only if your account is on the E2 version of the - platform or on a select custom plan that allows multiple workspaces per - account.` + Lists Databricks workspaces for an account.` cmd.Annotations = make(map[string]string) @@ -403,6 +371,7 @@ func newUpdate() *cobra.Command { cmd := &cobra.Command{} var updateReq provisioning.UpdateWorkspaceRequest + updateReq.CustomerFacingWorkspace = provisioning.Workspace{} var updateJson flags.JsonFlag var updateSkipWait bool @@ -413,151 +382,49 @@ func newUpdate() *cobra.Command { cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateReq.AwsRegion, "aws-region", updateReq.AwsRegion, `The AWS region of the workspace's data plane (for example, us-west-2).`) - cmd.Flags().StringVar(&updateReq.CredentialsId, "credentials-id", updateReq.CredentialsId, `ID of the workspace's credential configuration object.`) + cmd.Flags().StringVar(&updateReq.UpdateMask, "update-mask", updateReq.UpdateMask, `The field mask must be a single string, with multiple fields separated by commas (no spaces).`) + cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.AwsRegion, "aws-region", updateReq.CustomerFacingWorkspace.AwsRegion, ``) + // TODO: complex arg: azure_workspace_info + cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.Cloud, "cloud", updateReq.CustomerFacingWorkspace.Cloud, `The cloud name.`) + // TODO: complex arg: cloud_resource_container + cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.CredentialsId, "credentials-id", updateReq.CustomerFacingWorkspace.CredentialsId, `ID of the workspace's credential configuration object.`) // TODO: map via StringToStringVar: custom_tags - cmd.Flags().StringVar(&updateReq.ManagedServicesCustomerManagedKeyId, "managed-services-customer-managed-key-id", updateReq.ManagedServicesCustomerManagedKeyId, `The ID of the workspace's managed services encryption key configuration object.`) - cmd.Flags().StringVar(&updateReq.NetworkConnectivityConfigId, "network-connectivity-config-id", updateReq.NetworkConnectivityConfigId, ``) - cmd.Flags().StringVar(&updateReq.NetworkId, "network-id", updateReq.NetworkId, `The ID of the workspace's network configuration object.`) - cmd.Flags().StringVar(&updateReq.PrivateAccessSettingsId, "private-access-settings-id", updateReq.PrivateAccessSettingsId, `The ID of the workspace's private access settings configuration object.`) - cmd.Flags().StringVar(&updateReq.StorageConfigurationId, "storage-configuration-id", updateReq.StorageConfigurationId, `The ID of the workspace's storage configuration object.`) - cmd.Flags().StringVar(&updateReq.StorageCustomerManagedKeyId, "storage-customer-managed-key-id", updateReq.StorageCustomerManagedKeyId, `The ID of the key configuration object for workspace storage.`) + cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.DeploymentName, "deployment-name", updateReq.CustomerFacingWorkspace.DeploymentName, ``) + // TODO: complex arg: gcp_managed_network_config + // TODO: complex arg: gke_config + cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.Location, "location", updateReq.CustomerFacingWorkspace.Location, `The Google Cloud region of the workspace data plane in your Google account (for example, us-east4).`) + cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.ManagedServicesCustomerManagedKeyId, "managed-services-customer-managed-key-id", updateReq.CustomerFacingWorkspace.ManagedServicesCustomerManagedKeyId, `ID of the key configuration for encrypting managed services.`) + // TODO: complex arg: network + cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.NetworkConnectivityConfigId, "network-connectivity-config-id", updateReq.CustomerFacingWorkspace.NetworkConnectivityConfigId, `The object ID of network connectivity config.`) + cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.NetworkId, "network-id", updateReq.CustomerFacingWorkspace.NetworkId, `If this workspace is BYO VPC, then the network_id will be populated.`) + cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.PrivateAccessSettingsId, "private-access-settings-id", updateReq.CustomerFacingWorkspace.PrivateAccessSettingsId, `ID of the workspace's private access settings object.`) + cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.StorageConfigurationId, "storage-configuration-id", updateReq.CustomerFacingWorkspace.StorageConfigurationId, `ID of the workspace's storage configuration object.`) + cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.StorageCustomerManagedKeyId, "storage-customer-managed-key-id", updateReq.CustomerFacingWorkspace.StorageCustomerManagedKeyId, `ID of the key configuration for encrypting workspace storage.`) + cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.WorkspaceName, "workspace-name", updateReq.CustomerFacingWorkspace.WorkspaceName, `The human-readable name of the workspace.`) cmd.Use = "update WORKSPACE_ID" - cmd.Short = `Update workspace configuration.` - cmd.Long = `Update workspace configuration. - - Updates a workspace configuration for either a running workspace or a failed - workspace. The elements that can be updated varies between these two use - cases. - - ### Update a failed workspace You can update a Databricks workspace - configuration for failed workspace deployment for some fields, but not all - fields. For a failed workspace, this request supports updates to the following - fields only: - Credential configuration ID - Storage configuration ID - - Network configuration ID. Used only to add or change a network configuration - for a customer-managed VPC. For a failed workspace only, you can convert a - workspace with Databricks-managed VPC to use a customer-managed VPC by adding - this ID. You cannot downgrade a workspace with a customer-managed VPC to be a - Databricks-managed VPC. You can update the network configuration for a failed - or running workspace to add PrivateLink support, though you must also add a - private access settings object. - Key configuration ID for managed services - (control plane storage, such as notebook source and Databricks SQL queries). - Used only if you use customer-managed keys for managed services. - Key - configuration ID for workspace storage (root S3 bucket and, optionally, EBS - volumes). Used only if you use customer-managed keys for workspace storage. - **Important**: If the workspace was ever in the running state, even if briefly - before becoming a failed workspace, you cannot add a new key configuration ID - for workspace storage. - Private access settings ID to add PrivateLink - support. You can add or update the private access settings ID to upgrade a - workspace to add support for front-end, back-end, or both types of - connectivity. You cannot remove (downgrade) any existing front-end or back-end - PrivateLink support on a workspace. - Custom tags. Given you provide an empty - custom tags, the update would not be applied. - Network connectivity - configuration ID to add serverless stable IP support. You can add or update - the network connectivity configuration ID to ensure the workspace uses the - same set of stable IP CIDR blocks to access your resources. You cannot remove - a network connectivity configuration from the workspace once attached, you can - only switch to another one. - - After calling the PATCH operation to update the workspace configuration, - make repeated GET requests with the workspace ID and check the workspace - status. The workspace is successful if the status changes to RUNNING. - - For information about how to create a new workspace with this API **including - error handling**, see [Create a new workspace using the Account API]. + cmd.Short = `Update a workspace.` + cmd.Long = `Update a workspace. - ### Update a running workspace You can update a Databricks workspace - configuration for running workspaces for some fields, but not all fields. For - a running workspace, this request supports updating the following fields only: - - Credential configuration ID - Network configuration ID. Used only if you - already use a customer-managed VPC. You cannot convert a running workspace - from a Databricks-managed VPC to a customer-managed VPC. You can use a network - configuration update in this API for a failed or running workspace to add - support for PrivateLink, although you also need to add a private access - settings object. - Key configuration ID for managed services (control plane - storage, such as notebook source and Databricks SQL queries). Databricks does - not directly encrypt the data with the customer-managed key (CMK). Databricks - uses both the CMK and the Databricks managed key (DMK) that is unique to your - workspace to encrypt the Data Encryption Key (DEK). Databricks uses the DEK to - encrypt your workspace's managed services persisted data. If the workspace - does not already have a CMK for managed services, adding this ID enables - managed services encryption for new or updated data. Existing managed services - data that existed before adding the key remains not encrypted with the DEK - until it is modified. If the workspace already has customer-managed keys for - managed services, this request rotates (changes) the CMK keys and the DEK is - re-encrypted with the DMK and the new CMK. - Key configuration ID for - workspace storage (root S3 bucket and, optionally, EBS volumes). You can set - this only if the workspace does not already have a customer-managed key - configuration for workspace storage. - Private access settings ID to add - PrivateLink support. You can add or update the private access settings ID to - upgrade a workspace to add support for front-end, back-end, or both types of - connectivity. You cannot remove (downgrade) any existing front-end or back-end - PrivateLink support on a workspace. - Custom tags. Given you provide an empty - custom tags, the update would not be applied. - Network connectivity - configuration ID to add serverless stable IP support. You can add or update - the network connectivity configuration ID to ensure the workspace uses the - same set of stable IP CIDR blocks to access your resources. You cannot remove - a network connectivity configuration from the workspace once attached, you can - only switch to another one. - - **Important**: To update a running workspace, your workspace must have no - running compute resources that run in your workspace's VPC in the Classic data - plane. For example, stop all all-purpose clusters, job clusters, pools with - running clusters, and Classic SQL warehouses. If you do not terminate all - cluster instances in the workspace before calling this API, the request will - fail. - - ### Wait until changes take effect. After calling the PATCH operation to - update the workspace configuration, make repeated GET requests with the - workspace ID and check the workspace status and the status of the fields. * - For workspaces with a Databricks-managed VPC, the workspace status becomes - PROVISIONING temporarily (typically under 20 minutes). If the workspace - update is successful, the workspace status changes to RUNNING. Note that you - can also check the workspace status in the [Account Console]. However, you - cannot use or create clusters for another 20 minutes after that status change. - This results in a total of up to 40 minutes in which you cannot create - clusters. If you create or use clusters before this time interval elapses, - clusters do not launch successfully, fail, or could cause other unexpected - behavior. * For workspaces with a customer-managed VPC, the workspace status - stays at status RUNNING and the VPC change happens immediately. A change to - the storage customer-managed key configuration ID might take a few minutes to - update, so continue to check the workspace until you observe that it has been - updated. If the update fails, the workspace might revert silently to its - original configuration. After the workspace has been updated, you cannot use - or create clusters for another 20 minutes. If you create or use clusters - before this time interval elapses, clusters do not launch successfully, fail, - or could cause other unexpected behavior. - - If you update the _storage_ customer-managed key configurations, it takes 20 - minutes for the changes to fully take effect. During the 20 minute wait, it is - important that you stop all REST API calls to the DBFS API. If you are - modifying _only the managed services key configuration_, you can omit the 20 - minute wait. - - **Important**: Customer-managed keys and customer-managed VPCs are supported - by only some deployment types and subscription types. If you have questions - about availability, contact your Databricks representative. - - This operation is available only if your account is on the E2 version of the - platform or on a select custom plan that allows multiple workspaces per - account. - - [Account Console]: https://docs.databricks.com/administration-guide/account-settings-e2/account-console-e2.html - [Create a new workspace using the Account API]: http://docs.databricks.com/administration-guide/account-api/new-workspace.html + Updates a workspace. Arguments: - WORKSPACE_ID: Workspace ID.` + WORKSPACE_ID: A unique integer ID for the workspace` cmd.Annotations = make(map[string]string) + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) if cmd.Flags().Changed("json") { - diags := updateJson.Unmarshal(&updateReq) + diags := updateJson.Unmarshal(&updateReq.CustomerFacingWorkspace) if diags.HasError() { return diags.Error() } @@ -568,23 +435,6 @@ func newUpdate() *cobra.Command { } } } - if len(args) == 0 { - promptSpinner := cmdio.Spinner(ctx) - promptSpinner <- "No WORKSPACE_ID argument specified. Loading names for Workspaces drop-down." - names, err := a.Workspaces.WorkspaceWorkspaceNameToWorkspaceIdMap(ctx) - close(promptSpinner) - if err != nil { - return fmt.Errorf("failed to load names for Workspaces drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Workspace ID") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have workspace id") - } _, err = fmt.Sscan(args[0], &updateReq.WorkspaceId) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) @@ -595,7 +445,7 @@ func newUpdate() *cobra.Command { return err } if updateSkipWait { - return nil + return cmdio.Render(ctx, wait.Response) } spinner := cmdio.Spinner(ctx) info, err := wait.OnProgress(func(i *provisioning.Workspace) { diff --git a/cmd/workspace/apps/apps.go b/cmd/workspace/apps/apps.go index 6cf510f227..cc98bb786a 100755 --- a/cmd/workspace/apps/apps.go +++ b/cmd/workspace/apps/apps.go @@ -34,12 +34,14 @@ func New() *cobra.Command { // Add methods cmd.AddCommand(newCreate()) + cmd.AddCommand(newCreateUpdate()) cmd.AddCommand(newDelete()) cmd.AddCommand(newDeploy()) cmd.AddCommand(newGet()) cmd.AddCommand(newGetDeployment()) cmd.AddCommand(newGetPermissionLevels()) cmd.AddCommand(newGetPermissions()) + cmd.AddCommand(newGetUpdate()) cmd.AddCommand(newList()) cmd.AddCommand(newListDeployments()) cmd.AddCommand(newSetPermissions()) @@ -84,11 +86,13 @@ func newCreate() *cobra.Command { // TODO: complex arg: active_deployment // TODO: complex arg: app_status cmd.Flags().StringVar(&createReq.App.BudgetPolicyId, "budget-policy-id", createReq.App.BudgetPolicyId, ``) + cmd.Flags().Var(&createReq.App.ComputeSize, "compute-size", `Supported values: [LARGE, LIQUID, MEDIUM]`) // TODO: complex arg: compute_status cmd.Flags().StringVar(&createReq.App.Description, "description", createReq.App.Description, `The description of the app.`) // TODO: array: effective_user_api_scopes // TODO: complex arg: pending_deployment // TODO: array: resources + cmd.Flags().StringVar(&createReq.App.UsagePolicyId, "usage-policy-id", createReq.App.UsagePolicyId, ``) // TODO: array: user_api_scopes cmd.Use = "create NAME" @@ -174,6 +178,127 @@ func newCreate() *cobra.Command { return cmd } +// start create-update command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var createUpdateOverrides []func( + *cobra.Command, + *apps.AsyncUpdateAppRequest, +) + +func newCreateUpdate() *cobra.Command { + cmd := &cobra.Command{} + + var createUpdateReq apps.AsyncUpdateAppRequest + var createUpdateJson flags.JsonFlag + + var createUpdateSkipWait bool + var createUpdateTimeout time.Duration + + cmd.Flags().BoolVar(&createUpdateSkipWait, "no-wait", createUpdateSkipWait, `do not wait to reach SUCCEEDED state`) + cmd.Flags().DurationVar(&createUpdateTimeout, "timeout", 20*time.Minute, `maximum amount of time to reach SUCCEEDED state`) + + cmd.Flags().Var(&createUpdateJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + // TODO: complex arg: app + + cmd.Use = "create-update APP_NAME UPDATE_MASK" + cmd.Short = `Create an app update.` + cmd.Long = `Create an app update. + + Creates an app update and starts the update process. The update process is + asynchronous and the status of the update can be checked with the GetAppUpdate + method. + + Arguments: + APP_NAME: + UPDATE_MASK: The field mask must be a single string, with multiple fields separated by + commas (no spaces). The field path is relative to the resource object, + using a dot (.) to navigate sub-fields (e.g., author.given_name). + Specification of elements in sequence or map fields is not allowed, as + only the entire collection field can be specified. Field names must + exactly match the resource field names. + + A field mask of * indicates full replacement. It’s recommended to + always explicitly list the fields being updated and avoid using * + wildcards, as it can lead to unintended results if the API changes in the + future.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + if cmd.Flags().Changed("json") { + err := root.ExactArgs(1)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, provide only APP_NAME as positional arguments. Provide 'update_mask' in your JSON input") + } + return nil + } + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := createUpdateJson.Unmarshal(&createUpdateReq) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + createUpdateReq.AppName = args[0] + if !cmd.Flags().Changed("json") { + createUpdateReq.UpdateMask = args[1] + } + + wait, err := w.Apps.CreateUpdate(ctx, createUpdateReq) + if err != nil { + return err + } + if createUpdateSkipWait { + return cmdio.Render(ctx, wait.Response) + } + spinner := cmdio.Spinner(ctx) + info, err := wait.OnProgress(func(i *apps.AppUpdate) { + if i.Status == nil { + return + } + status := i.Status.State + statusMessage := fmt.Sprintf("current status: %s", status) + if i.Status != nil { + statusMessage = i.Status.Message + } + spinner <- statusMessage + }).GetWithTimeout(createUpdateTimeout) + close(spinner) + if err != nil { + return err + } + return cmdio.Render(ctx, info) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range createUpdateOverrides { + fn(cmd, &createUpdateReq) + } + + return cmd +} + // start delete command // Slice with functions to override default command behavior. @@ -561,6 +686,62 @@ func newGetPermissions() *cobra.Command { return cmd } +// start get-update command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var getUpdateOverrides []func( + *cobra.Command, + *apps.GetAppUpdateRequest, +) + +func newGetUpdate() *cobra.Command { + cmd := &cobra.Command{} + + var getUpdateReq apps.GetAppUpdateRequest + + cmd.Use = "get-update APP_NAME" + cmd.Short = `Get an app update.` + cmd.Long = `Get an app update. + + Gets the status of an app update. + + Arguments: + APP_NAME: The name of the app.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + getUpdateReq.AppName = args[0] + + response, err := w.Apps.GetUpdate(ctx, getUpdateReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range getUpdateOverrides { + fn(cmd, &getUpdateReq) + } + + return cmd +} + // start list command // Slice with functions to override default command behavior. @@ -926,11 +1107,13 @@ func newUpdate() *cobra.Command { // TODO: complex arg: active_deployment // TODO: complex arg: app_status cmd.Flags().StringVar(&updateReq.App.BudgetPolicyId, "budget-policy-id", updateReq.App.BudgetPolicyId, ``) + cmd.Flags().Var(&updateReq.App.ComputeSize, "compute-size", `Supported values: [LARGE, LIQUID, MEDIUM]`) // TODO: complex arg: compute_status cmd.Flags().StringVar(&updateReq.App.Description, "description", updateReq.App.Description, `The description of the app.`) // TODO: array: effective_user_api_scopes // TODO: complex arg: pending_deployment // TODO: array: resources + cmd.Flags().StringVar(&updateReq.App.UsagePolicyId, "usage-policy-id", updateReq.App.UsagePolicyId, ``) // TODO: array: user_api_scopes cmd.Use = "update NAME" diff --git a/cmd/workspace/catalogs/catalogs.go b/cmd/workspace/catalogs/catalogs.go index a7e442f7dc..77347cbd39 100755 --- a/cmd/workspace/catalogs/catalogs.go +++ b/cmd/workspace/catalogs/catalogs.go @@ -70,6 +70,8 @@ func newCreate() *cobra.Command { cmd.Flags().StringVar(&createReq.Comment, "comment", createReq.Comment, `User-provided free-form text description.`) cmd.Flags().StringVar(&createReq.ConnectionName, "connection-name", createReq.ConnectionName, `The name of the connection to an external data source.`) + // TODO: complex arg: conversion_info + // TODO: complex arg: dr_replication_info // TODO: map via StringToStringVar: options // TODO: map via StringToStringVar: properties cmd.Flags().StringVar(&createReq.ProviderName, "provider-name", createReq.ProviderName, `The name of delta sharing provider.`) @@ -274,6 +276,7 @@ func newList() *cobra.Command { var listReq catalog.ListCatalogsRequest cmd.Flags().BoolVar(&listReq.IncludeBrowse, "include-browse", listReq.IncludeBrowse, `Whether to include catalogs in the response for which the principal can only access selective metadata for.`) + cmd.Flags().BoolVar(&listReq.IncludeUnbound, "include-unbound", listReq.IncludeUnbound, `Whether to include catalogs not bound to the workspace.`) cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Maximum number of catalogs to return.`) cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Opaque pagination token to go to next page based on previous query.`) @@ -333,6 +336,8 @@ func newUpdate() *cobra.Command { cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) cmd.Flags().StringVar(&updateReq.Comment, "comment", updateReq.Comment, `User-provided free-form text description.`) + // TODO: complex arg: conversion_info + // TODO: complex arg: dr_replication_info cmd.Flags().Var(&updateReq.EnablePredictiveOptimization, "enable-predictive-optimization", `Whether predictive optimization should be enabled for this object and objects under it. Supported values: [DISABLE, ENABLE, INHERIT]`) cmd.Flags().Var(&updateReq.IsolationMode, "isolation-mode", `Whether the current securable is accessible from all workspaces or a specific set of workspaces. Supported values: [ISOLATED, OPEN]`) cmd.Flags().StringVar(&updateReq.NewName, "new-name", updateReq.NewName, `New name for the catalog.`) diff --git a/cmd/workspace/cmd.go b/cmd/workspace/cmd.go index 8be495af25..a8a86941a0 100755 --- a/cmd/workspace/cmd.go +++ b/cmd/workspace/cmd.go @@ -30,8 +30,10 @@ import ( current_user "github.com/databricks/cli/cmd/workspace/current-user" dashboard_widgets "github.com/databricks/cli/cmd/workspace/dashboard-widgets" dashboards "github.com/databricks/cli/cmd/workspace/dashboards" + data_quality "github.com/databricks/cli/cmd/workspace/data-quality" data_sources "github.com/databricks/cli/cmd/workspace/data-sources" database "github.com/databricks/cli/cmd/workspace/database" + database_project "github.com/databricks/cli/cmd/workspace/database-project" entity_tag_assignments "github.com/databricks/cli/cmd/workspace/entity-tag-assignments" experiments "github.com/databricks/cli/cmd/workspace/experiments" external_lineage "github.com/databricks/cli/cmd/workspace/external-lineage" @@ -78,6 +80,7 @@ import ( quality_monitors "github.com/databricks/cli/cmd/workspace/quality-monitors" queries "github.com/databricks/cli/cmd/workspace/queries" queries_legacy "github.com/databricks/cli/cmd/workspace/queries-legacy" + query_execution "github.com/databricks/cli/cmd/workspace/query-execution" query_history "github.com/databricks/cli/cmd/workspace/query-history" query_visualizations "github.com/databricks/cli/cmd/workspace/query-visualizations" query_visualizations_legacy "github.com/databricks/cli/cmd/workspace/query-visualizations-legacy" @@ -100,6 +103,7 @@ import ( system_schemas "github.com/databricks/cli/cmd/workspace/system-schemas" table_constraints "github.com/databricks/cli/cmd/workspace/table-constraints" tables "github.com/databricks/cli/cmd/workspace/tables" + tag_assignments "github.com/databricks/cli/cmd/workspace/tag-assignments" tag_policies "github.com/databricks/cli/cmd/workspace/tag-policies" temporary_path_credentials "github.com/databricks/cli/cmd/workspace/temporary-path-credentials" temporary_table_credentials "github.com/databricks/cli/cmd/workspace/temporary-table-credentials" @@ -152,8 +156,10 @@ func All() []*cobra.Command { out = append(out, current_user.New()) out = append(out, dashboard_widgets.New()) out = append(out, dashboards.New()) + out = append(out, data_quality.New()) out = append(out, data_sources.New()) out = append(out, database.New()) + out = append(out, database_project.New()) out = append(out, entity_tag_assignments.New()) out = append(out, experiments.New()) out = append(out, external_lineage.New()) @@ -199,6 +205,7 @@ func All() []*cobra.Command { out = append(out, quality_monitors.New()) out = append(out, queries.New()) out = append(out, queries_legacy.New()) + out = append(out, query_execution.New()) out = append(out, query_history.New()) out = append(out, query_visualizations.New()) out = append(out, query_visualizations_legacy.New()) @@ -221,6 +228,7 @@ func All() []*cobra.Command { out = append(out, system_schemas.New()) out = append(out, table_constraints.New()) out = append(out, tables.New()) + out = append(out, tag_assignments.New()) out = append(out, tag_policies.New()) out = append(out, temporary_path_credentials.New()) out = append(out, temporary_table_credentials.New()) diff --git a/cmd/workspace/connections/connections.go b/cmd/workspace/connections/connections.go index bae12cd8ef..761f278c29 100755 --- a/cmd/workspace/connections/connections.go +++ b/cmd/workspace/connections/connections.go @@ -72,6 +72,7 @@ func newCreate() *cobra.Command { cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) cmd.Flags().StringVar(&createReq.Comment, "comment", createReq.Comment, `User-provided free-form text description.`) + // TODO: complex arg: environment_settings // TODO: map via StringToStringVar: properties cmd.Flags().BoolVar(&createReq.ReadOnly, "read-only", createReq.ReadOnly, `If the connection is read only.`) @@ -330,6 +331,7 @@ func newUpdate() *cobra.Command { cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) + // TODO: complex arg: environment_settings cmd.Flags().StringVar(&updateReq.NewName, "new-name", updateReq.NewName, `New name for the connection.`) cmd.Flags().StringVar(&updateReq.Owner, "owner", updateReq.Owner, `Username of current owner of the connection.`) diff --git a/cmd/workspace/credentials/credentials.go b/cmd/workspace/credentials/credentials.go index 96b042b9b1..2f7504ed23 100755 --- a/cmd/workspace/credentials/credentials.go +++ b/cmd/workspace/credentials/credentials.go @@ -364,6 +364,7 @@ func newListCredentials() *cobra.Command { var listCredentialsReq catalog.ListCredentialsRequest + cmd.Flags().BoolVar(&listCredentialsReq.IncludeUnbound, "include-unbound", listCredentialsReq.IncludeUnbound, `Whether to include credentials not bound to the workspace.`) cmd.Flags().IntVar(&listCredentialsReq.MaxResults, "max-results", listCredentialsReq.MaxResults, `Maximum number of credentials to return.`) cmd.Flags().StringVar(&listCredentialsReq.PageToken, "page-token", listCredentialsReq.PageToken, `Opaque token to retrieve the next page of results.`) cmd.Flags().Var(&listCredentialsReq.Purpose, "purpose", `Return only credentials for the specified purpose. Supported values: [SERVICE, STORAGE]`) diff --git a/cmd/workspace/data-quality/data-quality.go b/cmd/workspace/data-quality/data-quality.go new file mode 100755 index 0000000000..d02ff35a2b --- /dev/null +++ b/cmd/workspace/data-quality/data-quality.go @@ -0,0 +1,891 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package data_quality + +import ( + "fmt" + + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/flags" + "github.com/databricks/databricks-sdk-go/service/dataquality" + "github.com/spf13/cobra" +) + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var cmdOverrides []func(*cobra.Command) + +func New() *cobra.Command { + cmd := &cobra.Command{ + Use: "data-quality", + Short: `Manage the data quality of Unity Catalog objects (currently support schema and table).`, + Long: `Manage the data quality of Unity Catalog objects (currently support schema + and table)`, + GroupID: "dataquality", + Annotations: map[string]string{ + "package": "dataquality", + }, + + // This service is being previewed; hide from help output. + Hidden: true, + RunE: root.ReportUnknownSubcommand, + } + + // Add methods + cmd.AddCommand(newCancelRefresh()) + cmd.AddCommand(newCreateMonitor()) + cmd.AddCommand(newCreateRefresh()) + cmd.AddCommand(newDeleteMonitor()) + cmd.AddCommand(newDeleteRefresh()) + cmd.AddCommand(newGetMonitor()) + cmd.AddCommand(newGetRefresh()) + cmd.AddCommand(newListMonitor()) + cmd.AddCommand(newListRefresh()) + cmd.AddCommand(newUpdateMonitor()) + cmd.AddCommand(newUpdateRefresh()) + + // Apply optional overrides to this command. + for _, fn := range cmdOverrides { + fn(cmd) + } + + return cmd +} + +// start cancel-refresh command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var cancelRefreshOverrides []func( + *cobra.Command, + *dataquality.CancelRefreshRequest, +) + +func newCancelRefresh() *cobra.Command { + cmd := &cobra.Command{} + + var cancelRefreshReq dataquality.CancelRefreshRequest + + cmd.Use = "cancel-refresh OBJECT_TYPE OBJECT_ID REFRESH_ID" + cmd.Short = `Cancel a refresh.` + cmd.Long = `Cancel a refresh. + + Cancels a data quality monitor refresh. Currently only supported for the + table object_type. + + Arguments: + OBJECT_TYPE: The type of the monitored object. Can be one of the following: schema or + table. + OBJECT_ID: The UUID of the request object. For example, schema id. + REFRESH_ID: Unique id of the refresh operation.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(3) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + cancelRefreshReq.ObjectType = args[0] + cancelRefreshReq.ObjectId = args[1] + _, err = fmt.Sscan(args[2], &cancelRefreshReq.RefreshId) + if err != nil { + return fmt.Errorf("invalid REFRESH_ID: %s", args[2]) + } + + response, err := w.DataQuality.CancelRefresh(ctx, cancelRefreshReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range cancelRefreshOverrides { + fn(cmd, &cancelRefreshReq) + } + + return cmd +} + +// start create-monitor command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var createMonitorOverrides []func( + *cobra.Command, + *dataquality.CreateMonitorRequest, +) + +func newCreateMonitor() *cobra.Command { + cmd := &cobra.Command{} + + var createMonitorReq dataquality.CreateMonitorRequest + createMonitorReq.Monitor = dataquality.Monitor{} + var createMonitorJson flags.JsonFlag + + cmd.Flags().Var(&createMonitorJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + // TODO: complex arg: anomaly_detection_config + // TODO: complex arg: data_profiling_config + + cmd.Use = "create-monitor OBJECT_TYPE OBJECT_ID" + cmd.Short = `Create a monitor.` + cmd.Long = `Create a monitor. + + Create a data quality monitor on a Unity Catalog object. The caller must + provide either anomaly_detection_config for a schema monitor or + data_profiling_config for a table monitor. + + For the table object_type, the caller must either: 1. be an owner of the + table's parent catalog, have **USE_SCHEMA** on the table's parent schema, and + have **SELECT** access on the table 2. have **USE_CATALOG** on the table's + parent catalog, be an owner of the table's parent schema, and have **SELECT** + access on the table. 3. have the following permissions: - **USE_CATALOG** on + the table's parent catalog - **USE_SCHEMA** on the table's parent schema - be + an owner of the table. + + Workspace assets, such as the dashboard, will be created in the workspace + where this call was made. + + Arguments: + OBJECT_TYPE: The type of the monitored object. Can be one of the following: schema or + table. + OBJECT_ID: The UUID of the request object. For example, schema id.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + if cmd.Flags().Changed("json") { + err := root.ExactArgs(0)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'object_type', 'object_id' in your JSON input") + } + return nil + } + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := createMonitorJson.Unmarshal(&createMonitorReq.Monitor) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + if !cmd.Flags().Changed("json") { + createMonitorReq.Monitor.ObjectType = args[0] + } + if !cmd.Flags().Changed("json") { + createMonitorReq.Monitor.ObjectId = args[1] + } + + response, err := w.DataQuality.CreateMonitor(ctx, createMonitorReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range createMonitorOverrides { + fn(cmd, &createMonitorReq) + } + + return cmd +} + +// start create-refresh command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var createRefreshOverrides []func( + *cobra.Command, + *dataquality.CreateRefreshRequest, +) + +func newCreateRefresh() *cobra.Command { + cmd := &cobra.Command{} + + var createRefreshReq dataquality.CreateRefreshRequest + createRefreshReq.Refresh = dataquality.Refresh{} + var createRefreshJson flags.JsonFlag + + cmd.Flags().Var(&createRefreshJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Use = "create-refresh OBJECT_TYPE OBJECT_ID" + cmd.Short = `Create a refresh.` + cmd.Long = `Create a refresh. + + Creates a refresh. Currently only supported for the table object_type. + + The caller must either: 1. be an owner of the table's parent catalog 2. have + **USE_CATALOG** on the table's parent catalog and be an owner of the table's + parent schema 3. have the following permissions: - **USE_CATALOG** on the + table's parent catalog - **USE_SCHEMA** on the table's parent schema - be an + owner of the table + + Arguments: + OBJECT_TYPE: The type of the monitored object. Can be one of the following: table. + OBJECT_ID: The UUID of the request object. For example, table id.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := createRefreshJson.Unmarshal(&createRefreshReq.Refresh) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + createRefreshReq.ObjectType = args[0] + createRefreshReq.ObjectId = args[1] + + response, err := w.DataQuality.CreateRefresh(ctx, createRefreshReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range createRefreshOverrides { + fn(cmd, &createRefreshReq) + } + + return cmd +} + +// start delete-monitor command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var deleteMonitorOverrides []func( + *cobra.Command, + *dataquality.DeleteMonitorRequest, +) + +func newDeleteMonitor() *cobra.Command { + cmd := &cobra.Command{} + + var deleteMonitorReq dataquality.DeleteMonitorRequest + + cmd.Use = "delete-monitor OBJECT_TYPE OBJECT_ID" + cmd.Short = `Delete a monitor.` + cmd.Long = `Delete a monitor. + + Delete a data quality monitor on Unity Catalog object. + + For the table object_type, the caller must either: 1. be an owner of the + table's parent catalog 2. have **USE_CATALOG** on the table's parent catalog + and be an owner of the table's parent schema 3. have the following + permissions: - **USE_CATALOG** on the table's parent catalog - **USE_SCHEMA** + on the table's parent schema - be an owner of the table. + + Note that the metric tables and dashboard will not be deleted as part of this + call; those assets must be manually cleaned up (if desired). + + Arguments: + OBJECT_TYPE: The type of the monitored object. Can be one of the following: schema or + table. + OBJECT_ID: The UUID of the request object. For example, schema id.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + deleteMonitorReq.ObjectType = args[0] + deleteMonitorReq.ObjectId = args[1] + + err = w.DataQuality.DeleteMonitor(ctx, deleteMonitorReq) + if err != nil { + return err + } + return nil + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range deleteMonitorOverrides { + fn(cmd, &deleteMonitorReq) + } + + return cmd +} + +// start delete-refresh command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var deleteRefreshOverrides []func( + *cobra.Command, + *dataquality.DeleteRefreshRequest, +) + +func newDeleteRefresh() *cobra.Command { + cmd := &cobra.Command{} + + var deleteRefreshReq dataquality.DeleteRefreshRequest + + cmd.Use = "delete-refresh OBJECT_TYPE OBJECT_ID REFRESH_ID" + cmd.Short = `Delete a refresh.` + cmd.Long = `Delete a refresh. + + (Unimplemented) Delete a refresh + + Arguments: + OBJECT_TYPE: The type of the monitored object. Can be one of the following: schema or + table. + OBJECT_ID: The UUID of the request object. For example, schema id. + REFRESH_ID: Unique id of the refresh operation.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(3) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + deleteRefreshReq.ObjectType = args[0] + deleteRefreshReq.ObjectId = args[1] + _, err = fmt.Sscan(args[2], &deleteRefreshReq.RefreshId) + if err != nil { + return fmt.Errorf("invalid REFRESH_ID: %s", args[2]) + } + + err = w.DataQuality.DeleteRefresh(ctx, deleteRefreshReq) + if err != nil { + return err + } + return nil + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range deleteRefreshOverrides { + fn(cmd, &deleteRefreshReq) + } + + return cmd +} + +// start get-monitor command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var getMonitorOverrides []func( + *cobra.Command, + *dataquality.GetMonitorRequest, +) + +func newGetMonitor() *cobra.Command { + cmd := &cobra.Command{} + + var getMonitorReq dataquality.GetMonitorRequest + + cmd.Use = "get-monitor OBJECT_TYPE OBJECT_ID" + cmd.Short = `Read a monitor.` + cmd.Long = `Read a monitor. + + Read a data quality monitor on Unity Catalog object. + + For the table object_type, the caller must either: 1. be an owner of the + table's parent catalog 2. have **USE_CATALOG** on the table's parent catalog + and be an owner of the table's parent schema. 3. have the following + permissions: - **USE_CATALOG** on the table's parent catalog - **USE_SCHEMA** + on the table's parent schema - **SELECT** privilege on the table. + + The returned information includes configuration values, as well as information + on assets created by the monitor. Some information (e.g., dashboard) may be + filtered out if the caller is in a different workspace than where the monitor + was created. + + Arguments: + OBJECT_TYPE: The type of the monitored object. Can be one of the following: schema or + table. + OBJECT_ID: The UUID of the request object. For example, schema id.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + getMonitorReq.ObjectType = args[0] + getMonitorReq.ObjectId = args[1] + + response, err := w.DataQuality.GetMonitor(ctx, getMonitorReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range getMonitorOverrides { + fn(cmd, &getMonitorReq) + } + + return cmd +} + +// start get-refresh command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var getRefreshOverrides []func( + *cobra.Command, + *dataquality.GetRefreshRequest, +) + +func newGetRefresh() *cobra.Command { + cmd := &cobra.Command{} + + var getRefreshReq dataquality.GetRefreshRequest + + cmd.Use = "get-refresh OBJECT_TYPE OBJECT_ID REFRESH_ID" + cmd.Short = `Get a refresh.` + cmd.Long = `Get a refresh. + + Get data quality monitor refresh. + + For the table object_type, the caller must either: 1. be an owner of the + table's parent catalog 2. have **USE_CATALOG** on the table's parent catalog + and be an owner of the table's parent schema 3. have the following + permissions: - **USE_CATALOG** on the table's parent catalog - **USE_SCHEMA** + on the table's parent schema - **SELECT** privilege on the table. + + Arguments: + OBJECT_TYPE: The type of the monitored object. Can be one of the following: schema or + table. + OBJECT_ID: The UUID of the request object. For example, schema id. + REFRESH_ID: Unique id of the refresh operation.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(3) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + getRefreshReq.ObjectType = args[0] + getRefreshReq.ObjectId = args[1] + _, err = fmt.Sscan(args[2], &getRefreshReq.RefreshId) + if err != nil { + return fmt.Errorf("invalid REFRESH_ID: %s", args[2]) + } + + response, err := w.DataQuality.GetRefresh(ctx, getRefreshReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range getRefreshOverrides { + fn(cmd, &getRefreshReq) + } + + return cmd +} + +// start list-monitor command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var listMonitorOverrides []func( + *cobra.Command, + *dataquality.ListMonitorRequest, +) + +func newListMonitor() *cobra.Command { + cmd := &cobra.Command{} + + var listMonitorReq dataquality.ListMonitorRequest + + cmd.Flags().IntVar(&listMonitorReq.PageSize, "page-size", listMonitorReq.PageSize, ``) + cmd.Flags().StringVar(&listMonitorReq.PageToken, "page-token", listMonitorReq.PageToken, ``) + + cmd.Use = "list-monitor" + cmd.Short = `List monitors.` + cmd.Long = `List monitors. + + (Unimplemented) List data quality monitors.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(0) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + response := w.DataQuality.ListMonitor(ctx, listMonitorReq) + return cmdio.RenderIterator(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range listMonitorOverrides { + fn(cmd, &listMonitorReq) + } + + return cmd +} + +// start list-refresh command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var listRefreshOverrides []func( + *cobra.Command, + *dataquality.ListRefreshRequest, +) + +func newListRefresh() *cobra.Command { + cmd := &cobra.Command{} + + var listRefreshReq dataquality.ListRefreshRequest + + cmd.Flags().IntVar(&listRefreshReq.PageSize, "page-size", listRefreshReq.PageSize, ``) + cmd.Flags().StringVar(&listRefreshReq.PageToken, "page-token", listRefreshReq.PageToken, ``) + + cmd.Use = "list-refresh OBJECT_TYPE OBJECT_ID" + cmd.Short = `List refreshes.` + cmd.Long = `List refreshes. + + List data quality monitor refreshes. + + For the table object_type, the caller must either: 1. be an owner of the + table's parent catalog 2. have **USE_CATALOG** on the table's parent catalog + and be an owner of the table's parent schema 3. have the following + permissions: - **USE_CATALOG** on the table's parent catalog - **USE_SCHEMA** + on the table's parent schema - **SELECT** privilege on the table. + + Arguments: + OBJECT_TYPE: The type of the monitored object. Can be one of the following: schema or + table. + OBJECT_ID: The UUID of the request object. For example, schema id.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + listRefreshReq.ObjectType = args[0] + listRefreshReq.ObjectId = args[1] + + response := w.DataQuality.ListRefresh(ctx, listRefreshReq) + return cmdio.RenderIterator(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range listRefreshOverrides { + fn(cmd, &listRefreshReq) + } + + return cmd +} + +// start update-monitor command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var updateMonitorOverrides []func( + *cobra.Command, + *dataquality.UpdateMonitorRequest, +) + +func newUpdateMonitor() *cobra.Command { + cmd := &cobra.Command{} + + var updateMonitorReq dataquality.UpdateMonitorRequest + updateMonitorReq.Monitor = dataquality.Monitor{} + var updateMonitorJson flags.JsonFlag + + cmd.Flags().Var(&updateMonitorJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + // TODO: complex arg: anomaly_detection_config + // TODO: complex arg: data_profiling_config + + cmd.Use = "update-monitor OBJECT_TYPE OBJECT_ID UPDATE_MASK OBJECT_TYPE OBJECT_ID" + cmd.Short = `Update a monitor.` + cmd.Long = `Update a monitor. + + Update a data quality monitor on Unity Catalog object. + + For the table object_type, The caller must either: 1. be an owner of the + table's parent catalog 2. have **USE_CATALOG** on the table's parent catalog + and be an owner of the table's parent schema 3. have the following + permissions: - **USE_CATALOG** on the table's parent catalog - **USE_SCHEMA** + on the table's parent schema - be an owner of the table. + + Arguments: + OBJECT_TYPE: The type of the monitored object. Can be one of the following: schema or + table. + OBJECT_ID: The UUID of the request object. For example, schema id. + UPDATE_MASK: The field mask to specify which fields to update. + OBJECT_TYPE: The type of the monitored object. Can be one of the following: schema or + table. + OBJECT_ID: The UUID of the request object. For example, schema id.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + if cmd.Flags().Changed("json") { + err := root.ExactArgs(3)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, provide only OBJECT_TYPE, OBJECT_ID, UPDATE_MASK as positional arguments. Provide 'object_type', 'object_id' in your JSON input") + } + return nil + } + check := root.ExactArgs(5) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := updateMonitorJson.Unmarshal(&updateMonitorReq.Monitor) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + updateMonitorReq.ObjectType = args[0] + updateMonitorReq.ObjectId = args[1] + updateMonitorReq.UpdateMask = args[2] + if !cmd.Flags().Changed("json") { + updateMonitorReq.Monitor.ObjectType = args[3] + } + if !cmd.Flags().Changed("json") { + updateMonitorReq.Monitor.ObjectId = args[4] + } + + response, err := w.DataQuality.UpdateMonitor(ctx, updateMonitorReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range updateMonitorOverrides { + fn(cmd, &updateMonitorReq) + } + + return cmd +} + +// start update-refresh command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var updateRefreshOverrides []func( + *cobra.Command, + *dataquality.UpdateRefreshRequest, +) + +func newUpdateRefresh() *cobra.Command { + cmd := &cobra.Command{} + + var updateRefreshReq dataquality.UpdateRefreshRequest + updateRefreshReq.Refresh = dataquality.Refresh{} + var updateRefreshJson flags.JsonFlag + + cmd.Flags().Var(&updateRefreshJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Use = "update-refresh OBJECT_TYPE OBJECT_ID REFRESH_ID UPDATE_MASK OBJECT_TYPE OBJECT_ID" + cmd.Short = `Update a refresh.` + cmd.Long = `Update a refresh. + + (Unimplemented) Update a refresh + + Arguments: + OBJECT_TYPE: The type of the monitored object. Can be one of the following: schema or + table. + OBJECT_ID: The UUID of the request object. For example, schema id. + REFRESH_ID: Unique id of the refresh operation. + UPDATE_MASK: The field mask to specify which fields to update. + OBJECT_TYPE: The type of the monitored object. Can be one of the following: table. + OBJECT_ID: The UUID of the request object. For example, table id.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + if cmd.Flags().Changed("json") { + err := root.ExactArgs(4)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, provide only OBJECT_TYPE, OBJECT_ID, REFRESH_ID, UPDATE_MASK as positional arguments. Provide 'object_type', 'object_id' in your JSON input") + } + return nil + } + check := root.ExactArgs(6) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := updateRefreshJson.Unmarshal(&updateRefreshReq.Refresh) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + updateRefreshReq.ObjectType = args[0] + updateRefreshReq.ObjectId = args[1] + _, err = fmt.Sscan(args[2], &updateRefreshReq.RefreshId) + if err != nil { + return fmt.Errorf("invalid REFRESH_ID: %s", args[2]) + } + updateRefreshReq.UpdateMask = args[3] + if !cmd.Flags().Changed("json") { + updateRefreshReq.Refresh.ObjectType = args[4] + } + if !cmd.Flags().Changed("json") { + updateRefreshReq.Refresh.ObjectId = args[5] + } + + response, err := w.DataQuality.UpdateRefresh(ctx, updateRefreshReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range updateRefreshOverrides { + fn(cmd, &updateRefreshReq) + } + + return cmd +} + +// end service DataQuality diff --git a/cmd/workspace/database-project/database-project.go b/cmd/workspace/database-project/database-project.go new file mode 100755 index 0000000000..d4532f4747 --- /dev/null +++ b/cmd/workspace/database-project/database-project.go @@ -0,0 +1,1062 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package database_project + +import ( + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/flags" + "github.com/databricks/databricks-sdk-go/service/database" + "github.com/spf13/cobra" +) + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var cmdOverrides []func(*cobra.Command) + +func New() *cobra.Command { + cmd := &cobra.Command{ + Use: "database-project", + Short: `Database Projects provide access to a database via REST API or direct SQL.`, + Long: `Database Projects provide access to a database via REST API or direct SQL.`, + GroupID: "database", + Annotations: map[string]string{ + "package": "database", + }, + + // This service is being previewed; hide from help output. + Hidden: true, + RunE: root.ReportUnknownSubcommand, + } + + // Add methods + cmd.AddCommand(newCreateDatabaseBranch()) + cmd.AddCommand(newCreateDatabaseEndpoint()) + cmd.AddCommand(newCreateDatabaseProject()) + cmd.AddCommand(newDeleteDatabaseBranch()) + cmd.AddCommand(newDeleteDatabaseEndpoint()) + cmd.AddCommand(newDeleteDatabaseProject()) + cmd.AddCommand(newGetDatabaseBranch()) + cmd.AddCommand(newGetDatabaseEndpoint()) + cmd.AddCommand(newGetDatabaseProject()) + cmd.AddCommand(newListDatabaseBranches()) + cmd.AddCommand(newListDatabaseEndpoints()) + cmd.AddCommand(newListDatabaseProjects()) + cmd.AddCommand(newRestartDatabaseEndpoint()) + cmd.AddCommand(newUpdateDatabaseBranch()) + cmd.AddCommand(newUpdateDatabaseEndpoint()) + cmd.AddCommand(newUpdateDatabaseProject()) + + // Apply optional overrides to this command. + for _, fn := range cmdOverrides { + fn(cmd) + } + + return cmd +} + +// start create-database-branch command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var createDatabaseBranchOverrides []func( + *cobra.Command, + *database.CreateDatabaseBranchRequest, +) + +func newCreateDatabaseBranch() *cobra.Command { + cmd := &cobra.Command{} + + var createDatabaseBranchReq database.CreateDatabaseBranchRequest + createDatabaseBranchReq.DatabaseBranch = database.DatabaseBranch{} + var createDatabaseBranchJson flags.JsonFlag + + cmd.Flags().Var(&createDatabaseBranchJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&createDatabaseBranchReq.DatabaseBranch.BranchId, "branch-id", createDatabaseBranchReq.DatabaseBranch.BranchId, ``) + cmd.Flags().BoolVar(&createDatabaseBranchReq.DatabaseBranch.Default, "default", createDatabaseBranchReq.DatabaseBranch.Default, `Whether the branch is the project's default branch.`) + cmd.Flags().BoolVar(&createDatabaseBranchReq.DatabaseBranch.IsProtected, "is-protected", createDatabaseBranchReq.DatabaseBranch.IsProtected, `Whether the branch is protected.`) + cmd.Flags().StringVar(&createDatabaseBranchReq.DatabaseBranch.ParentId, "parent-id", createDatabaseBranchReq.DatabaseBranch.ParentId, `The id of the parent branch.`) + cmd.Flags().StringVar(&createDatabaseBranchReq.DatabaseBranch.ParentLsn, "parent-lsn", createDatabaseBranchReq.DatabaseBranch.ParentLsn, `The Log Sequence Number (LSN) on the parent branch from which this branch was created.`) + cmd.Flags().StringVar(&createDatabaseBranchReq.DatabaseBranch.ParentTime, "parent-time", createDatabaseBranchReq.DatabaseBranch.ParentTime, `The point in time on the parent branch from which this branch was created.`) + + cmd.Use = "create-database-branch PROJECT_ID" + cmd.Short = `Create a Database Branch.` + cmd.Long = `Create a Database Branch.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := createDatabaseBranchJson.Unmarshal(&createDatabaseBranchReq.DatabaseBranch) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + createDatabaseBranchReq.ProjectId = args[0] + + response, err := w.DatabaseProject.CreateDatabaseBranch(ctx, createDatabaseBranchReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range createDatabaseBranchOverrides { + fn(cmd, &createDatabaseBranchReq) + } + + return cmd +} + +// start create-database-endpoint command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var createDatabaseEndpointOverrides []func( + *cobra.Command, + *database.CreateDatabaseEndpointRequest, +) + +func newCreateDatabaseEndpoint() *cobra.Command { + cmd := &cobra.Command{} + + var createDatabaseEndpointReq database.CreateDatabaseEndpointRequest + createDatabaseEndpointReq.DatabaseEndpoint = database.DatabaseEndpoint{} + var createDatabaseEndpointJson flags.JsonFlag + + cmd.Flags().Var(&createDatabaseEndpointJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().Float64Var(&createDatabaseEndpointReq.DatabaseEndpoint.AutoscalingLimitMaxCu, "autoscaling-limit-max-cu", createDatabaseEndpointReq.DatabaseEndpoint.AutoscalingLimitMaxCu, `The maximum number of Compute Units.`) + cmd.Flags().Float64Var(&createDatabaseEndpointReq.DatabaseEndpoint.AutoscalingLimitMinCu, "autoscaling-limit-min-cu", createDatabaseEndpointReq.DatabaseEndpoint.AutoscalingLimitMinCu, `The minimum number of Compute Units.`) + cmd.Flags().BoolVar(&createDatabaseEndpointReq.DatabaseEndpoint.Disabled, "disabled", createDatabaseEndpointReq.DatabaseEndpoint.Disabled, `Whether to restrict connections to the compute endpoint.`) + cmd.Flags().StringVar(&createDatabaseEndpointReq.DatabaseEndpoint.EndpointId, "endpoint-id", createDatabaseEndpointReq.DatabaseEndpoint.EndpointId, ``) + cmd.Flags().Var(&createDatabaseEndpointReq.DatabaseEndpoint.PoolerMode, "pooler-mode", `Supported values: [TRANSACTION]`) + // TODO: complex arg: settings + cmd.Flags().StringVar(&createDatabaseEndpointReq.DatabaseEndpoint.SuspendTimeoutDuration, "suspend-timeout-duration", createDatabaseEndpointReq.DatabaseEndpoint.SuspendTimeoutDuration, `Duration of inactivity after which the compute endpoint is automatically suspended.`) + cmd.Flags().Var(&createDatabaseEndpointReq.DatabaseEndpoint.Type, "type", `NOTE: if want type to default to some value set the server then an effective_type field OR make this field REQUIRED. Supported values: [READ_ONLY, READ_WRITE]`) + + cmd.Use = "create-database-endpoint PROJECT_ID BRANCH_ID" + cmd.Short = `Create a Database Endpoint.` + cmd.Long = `Create a Database Endpoint.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := createDatabaseEndpointJson.Unmarshal(&createDatabaseEndpointReq.DatabaseEndpoint) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + createDatabaseEndpointReq.ProjectId = args[0] + createDatabaseEndpointReq.BranchId = args[1] + + response, err := w.DatabaseProject.CreateDatabaseEndpoint(ctx, createDatabaseEndpointReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range createDatabaseEndpointOverrides { + fn(cmd, &createDatabaseEndpointReq) + } + + return cmd +} + +// start create-database-project command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var createDatabaseProjectOverrides []func( + *cobra.Command, + *database.CreateDatabaseProjectRequest, +) + +func newCreateDatabaseProject() *cobra.Command { + cmd := &cobra.Command{} + + var createDatabaseProjectReq database.CreateDatabaseProjectRequest + createDatabaseProjectReq.DatabaseProject = database.DatabaseProject{} + var createDatabaseProjectJson flags.JsonFlag + + cmd.Flags().Var(&createDatabaseProjectJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&createDatabaseProjectReq.DatabaseProject.BudgetPolicyId, "budget-policy-id", createDatabaseProjectReq.DatabaseProject.BudgetPolicyId, `The desired budget policy to associate with the instance.`) + // TODO: array: custom_tags + // TODO: complex arg: default_endpoint_settings + cmd.Flags().StringVar(&createDatabaseProjectReq.DatabaseProject.DisplayName, "display-name", createDatabaseProjectReq.DatabaseProject.DisplayName, `Human-readable project name.`) + // TODO: complex arg: effective_default_endpoint_settings + // TODO: complex arg: effective_settings + cmd.Flags().StringVar(&createDatabaseProjectReq.DatabaseProject.HistoryRetentionDuration, "history-retention-duration", createDatabaseProjectReq.DatabaseProject.HistoryRetentionDuration, `The number of seconds to retain the shared history for point in time recovery for all branches in this project.`) + cmd.Flags().IntVar(&createDatabaseProjectReq.DatabaseProject.PgVersion, "pg-version", createDatabaseProjectReq.DatabaseProject.PgVersion, `The major Postgres version number.`) + cmd.Flags().StringVar(&createDatabaseProjectReq.DatabaseProject.ProjectId, "project-id", createDatabaseProjectReq.DatabaseProject.ProjectId, ``) + // TODO: complex arg: settings + + cmd.Use = "create-database-project" + cmd.Short = `Create a Database Project.` + cmd.Long = `Create a Database Project.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(0) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := createDatabaseProjectJson.Unmarshal(&createDatabaseProjectReq.DatabaseProject) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + + response, err := w.DatabaseProject.CreateDatabaseProject(ctx, createDatabaseProjectReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range createDatabaseProjectOverrides { + fn(cmd, &createDatabaseProjectReq) + } + + return cmd +} + +// start delete-database-branch command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var deleteDatabaseBranchOverrides []func( + *cobra.Command, + *database.DeleteDatabaseBranchRequest, +) + +func newDeleteDatabaseBranch() *cobra.Command { + cmd := &cobra.Command{} + + var deleteDatabaseBranchReq database.DeleteDatabaseBranchRequest + + cmd.Use = "delete-database-branch PROJECT_ID BRANCH_ID" + cmd.Short = `Delete a Database Branch.` + cmd.Long = `Delete a Database Branch.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + deleteDatabaseBranchReq.ProjectId = args[0] + deleteDatabaseBranchReq.BranchId = args[1] + + err = w.DatabaseProject.DeleteDatabaseBranch(ctx, deleteDatabaseBranchReq) + if err != nil { + return err + } + return nil + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range deleteDatabaseBranchOverrides { + fn(cmd, &deleteDatabaseBranchReq) + } + + return cmd +} + +// start delete-database-endpoint command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var deleteDatabaseEndpointOverrides []func( + *cobra.Command, + *database.DeleteDatabaseEndpointRequest, +) + +func newDeleteDatabaseEndpoint() *cobra.Command { + cmd := &cobra.Command{} + + var deleteDatabaseEndpointReq database.DeleteDatabaseEndpointRequest + + cmd.Use = "delete-database-endpoint PROJECT_ID BRANCH_ID ENDPOINT_ID" + cmd.Short = `Delete a Database Endpoint.` + cmd.Long = `Delete a Database Endpoint.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(3) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + deleteDatabaseEndpointReq.ProjectId = args[0] + deleteDatabaseEndpointReq.BranchId = args[1] + deleteDatabaseEndpointReq.EndpointId = args[2] + + err = w.DatabaseProject.DeleteDatabaseEndpoint(ctx, deleteDatabaseEndpointReq) + if err != nil { + return err + } + return nil + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range deleteDatabaseEndpointOverrides { + fn(cmd, &deleteDatabaseEndpointReq) + } + + return cmd +} + +// start delete-database-project command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var deleteDatabaseProjectOverrides []func( + *cobra.Command, + *database.DeleteDatabaseProjectRequest, +) + +func newDeleteDatabaseProject() *cobra.Command { + cmd := &cobra.Command{} + + var deleteDatabaseProjectReq database.DeleteDatabaseProjectRequest + + cmd.Use = "delete-database-project PROJECT_ID" + cmd.Short = `Delete a Database Project.` + cmd.Long = `Delete a Database Project.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + deleteDatabaseProjectReq.ProjectId = args[0] + + err = w.DatabaseProject.DeleteDatabaseProject(ctx, deleteDatabaseProjectReq) + if err != nil { + return err + } + return nil + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range deleteDatabaseProjectOverrides { + fn(cmd, &deleteDatabaseProjectReq) + } + + return cmd +} + +// start get-database-branch command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var getDatabaseBranchOverrides []func( + *cobra.Command, + *database.GetDatabaseBranchRequest, +) + +func newGetDatabaseBranch() *cobra.Command { + cmd := &cobra.Command{} + + var getDatabaseBranchReq database.GetDatabaseBranchRequest + + cmd.Use = "get-database-branch PROJECT_ID BRANCH_ID" + cmd.Short = `Get a Database Branch.` + cmd.Long = `Get a Database Branch.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + getDatabaseBranchReq.ProjectId = args[0] + getDatabaseBranchReq.BranchId = args[1] + + response, err := w.DatabaseProject.GetDatabaseBranch(ctx, getDatabaseBranchReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range getDatabaseBranchOverrides { + fn(cmd, &getDatabaseBranchReq) + } + + return cmd +} + +// start get-database-endpoint command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var getDatabaseEndpointOverrides []func( + *cobra.Command, + *database.GetDatabaseEndpointRequest, +) + +func newGetDatabaseEndpoint() *cobra.Command { + cmd := &cobra.Command{} + + var getDatabaseEndpointReq database.GetDatabaseEndpointRequest + + cmd.Use = "get-database-endpoint PROJECT_ID BRANCH_ID ENDPOINT_ID" + cmd.Short = `Get a Database Endpoint.` + cmd.Long = `Get a Database Endpoint.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(3) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + getDatabaseEndpointReq.ProjectId = args[0] + getDatabaseEndpointReq.BranchId = args[1] + getDatabaseEndpointReq.EndpointId = args[2] + + response, err := w.DatabaseProject.GetDatabaseEndpoint(ctx, getDatabaseEndpointReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range getDatabaseEndpointOverrides { + fn(cmd, &getDatabaseEndpointReq) + } + + return cmd +} + +// start get-database-project command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var getDatabaseProjectOverrides []func( + *cobra.Command, + *database.GetDatabaseProjectRequest, +) + +func newGetDatabaseProject() *cobra.Command { + cmd := &cobra.Command{} + + var getDatabaseProjectReq database.GetDatabaseProjectRequest + + cmd.Use = "get-database-project PROJECT_ID" + cmd.Short = `Get a Database Project.` + cmd.Long = `Get a Database Project.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + getDatabaseProjectReq.ProjectId = args[0] + + response, err := w.DatabaseProject.GetDatabaseProject(ctx, getDatabaseProjectReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range getDatabaseProjectOverrides { + fn(cmd, &getDatabaseProjectReq) + } + + return cmd +} + +// start list-database-branches command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var listDatabaseBranchesOverrides []func( + *cobra.Command, + *database.ListDatabaseBranchesRequest, +) + +func newListDatabaseBranches() *cobra.Command { + cmd := &cobra.Command{} + + var listDatabaseBranchesReq database.ListDatabaseBranchesRequest + + cmd.Flags().IntVar(&listDatabaseBranchesReq.PageSize, "page-size", listDatabaseBranchesReq.PageSize, `Upper bound for items returned.`) + cmd.Flags().StringVar(&listDatabaseBranchesReq.PageToken, "page-token", listDatabaseBranchesReq.PageToken, `Pagination token to go to the next page of Database Branches.`) + + cmd.Use = "list-database-branches PROJECT_ID" + cmd.Short = `List Database Branches.` + cmd.Long = `List Database Branches.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + listDatabaseBranchesReq.ProjectId = args[0] + + response := w.DatabaseProject.ListDatabaseBranches(ctx, listDatabaseBranchesReq) + return cmdio.RenderIterator(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range listDatabaseBranchesOverrides { + fn(cmd, &listDatabaseBranchesReq) + } + + return cmd +} + +// start list-database-endpoints command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var listDatabaseEndpointsOverrides []func( + *cobra.Command, + *database.ListDatabaseEndpointsRequest, +) + +func newListDatabaseEndpoints() *cobra.Command { + cmd := &cobra.Command{} + + var listDatabaseEndpointsReq database.ListDatabaseEndpointsRequest + + cmd.Flags().IntVar(&listDatabaseEndpointsReq.PageSize, "page-size", listDatabaseEndpointsReq.PageSize, `Upper bound for items returned.`) + cmd.Flags().StringVar(&listDatabaseEndpointsReq.PageToken, "page-token", listDatabaseEndpointsReq.PageToken, `Pagination token to go to the next page of Database Endpoints.`) + + cmd.Use = "list-database-endpoints PROJECT_ID BRANCH_ID" + cmd.Short = `List Database Endpoints.` + cmd.Long = `List Database Endpoints.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + listDatabaseEndpointsReq.ProjectId = args[0] + listDatabaseEndpointsReq.BranchId = args[1] + + response := w.DatabaseProject.ListDatabaseEndpoints(ctx, listDatabaseEndpointsReq) + return cmdio.RenderIterator(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range listDatabaseEndpointsOverrides { + fn(cmd, &listDatabaseEndpointsReq) + } + + return cmd +} + +// start list-database-projects command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var listDatabaseProjectsOverrides []func( + *cobra.Command, + *database.ListDatabaseProjectsRequest, +) + +func newListDatabaseProjects() *cobra.Command { + cmd := &cobra.Command{} + + var listDatabaseProjectsReq database.ListDatabaseProjectsRequest + + cmd.Flags().IntVar(&listDatabaseProjectsReq.PageSize, "page-size", listDatabaseProjectsReq.PageSize, `Upper bound for items returned.`) + cmd.Flags().StringVar(&listDatabaseProjectsReq.PageToken, "page-token", listDatabaseProjectsReq.PageToken, `Pagination token to go to the next page of Database Projects.`) + + cmd.Use = "list-database-projects" + cmd.Short = `List Database Instances.` + cmd.Long = `List Database Instances.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(0) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + response := w.DatabaseProject.ListDatabaseProjects(ctx, listDatabaseProjectsReq) + return cmdio.RenderIterator(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range listDatabaseProjectsOverrides { + fn(cmd, &listDatabaseProjectsReq) + } + + return cmd +} + +// start restart-database-endpoint command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var restartDatabaseEndpointOverrides []func( + *cobra.Command, + *database.RestartDatabaseEndpointRequest, +) + +func newRestartDatabaseEndpoint() *cobra.Command { + cmd := &cobra.Command{} + + var restartDatabaseEndpointReq database.RestartDatabaseEndpointRequest + + cmd.Use = "restart-database-endpoint PROJECT_ID BRANCH_ID ENDPOINT_ID" + cmd.Short = `Restart a Database Endpoint.` + cmd.Long = `Restart a Database Endpoint. + + Restart a Database Endpoint. TODO: should return + databricks.longrunning.Operation` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(3) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + restartDatabaseEndpointReq.ProjectId = args[0] + restartDatabaseEndpointReq.BranchId = args[1] + restartDatabaseEndpointReq.EndpointId = args[2] + + response, err := w.DatabaseProject.RestartDatabaseEndpoint(ctx, restartDatabaseEndpointReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range restartDatabaseEndpointOverrides { + fn(cmd, &restartDatabaseEndpointReq) + } + + return cmd +} + +// start update-database-branch command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var updateDatabaseBranchOverrides []func( + *cobra.Command, + *database.UpdateDatabaseBranchRequest, +) + +func newUpdateDatabaseBranch() *cobra.Command { + cmd := &cobra.Command{} + + var updateDatabaseBranchReq database.UpdateDatabaseBranchRequest + updateDatabaseBranchReq.DatabaseBranch = database.DatabaseBranch{} + var updateDatabaseBranchJson flags.JsonFlag + + cmd.Flags().Var(&updateDatabaseBranchJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&updateDatabaseBranchReq.DatabaseBranch.BranchId, "branch-id", updateDatabaseBranchReq.DatabaseBranch.BranchId, ``) + cmd.Flags().BoolVar(&updateDatabaseBranchReq.DatabaseBranch.Default, "default", updateDatabaseBranchReq.DatabaseBranch.Default, `Whether the branch is the project's default branch.`) + cmd.Flags().BoolVar(&updateDatabaseBranchReq.DatabaseBranch.IsProtected, "is-protected", updateDatabaseBranchReq.DatabaseBranch.IsProtected, `Whether the branch is protected.`) + cmd.Flags().StringVar(&updateDatabaseBranchReq.DatabaseBranch.ParentId, "parent-id", updateDatabaseBranchReq.DatabaseBranch.ParentId, `The id of the parent branch.`) + cmd.Flags().StringVar(&updateDatabaseBranchReq.DatabaseBranch.ParentLsn, "parent-lsn", updateDatabaseBranchReq.DatabaseBranch.ParentLsn, `The Log Sequence Number (LSN) on the parent branch from which this branch was created.`) + cmd.Flags().StringVar(&updateDatabaseBranchReq.DatabaseBranch.ParentTime, "parent-time", updateDatabaseBranchReq.DatabaseBranch.ParentTime, `The point in time on the parent branch from which this branch was created.`) + + cmd.Use = "update-database-branch PROJECT_ID BRANCH_ID UPDATE_MASK" + cmd.Short = `Update a Database Branch.` + cmd.Long = `Update a Database Branch. + + Arguments: + PROJECT_ID: + BRANCH_ID: + UPDATE_MASK: The list of fields to update. If unspecified, all fields will be updated + when possible.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(3) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := updateDatabaseBranchJson.Unmarshal(&updateDatabaseBranchReq.DatabaseBranch) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + updateDatabaseBranchReq.ProjectId = args[0] + updateDatabaseBranchReq.BranchId = args[1] + updateDatabaseBranchReq.UpdateMask = args[2] + + response, err := w.DatabaseProject.UpdateDatabaseBranch(ctx, updateDatabaseBranchReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range updateDatabaseBranchOverrides { + fn(cmd, &updateDatabaseBranchReq) + } + + return cmd +} + +// start update-database-endpoint command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var updateDatabaseEndpointOverrides []func( + *cobra.Command, + *database.UpdateDatabaseEndpointRequest, +) + +func newUpdateDatabaseEndpoint() *cobra.Command { + cmd := &cobra.Command{} + + var updateDatabaseEndpointReq database.UpdateDatabaseEndpointRequest + updateDatabaseEndpointReq.DatabaseEndpoint = database.DatabaseEndpoint{} + var updateDatabaseEndpointJson flags.JsonFlag + + cmd.Flags().Var(&updateDatabaseEndpointJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().Float64Var(&updateDatabaseEndpointReq.DatabaseEndpoint.AutoscalingLimitMaxCu, "autoscaling-limit-max-cu", updateDatabaseEndpointReq.DatabaseEndpoint.AutoscalingLimitMaxCu, `The maximum number of Compute Units.`) + cmd.Flags().Float64Var(&updateDatabaseEndpointReq.DatabaseEndpoint.AutoscalingLimitMinCu, "autoscaling-limit-min-cu", updateDatabaseEndpointReq.DatabaseEndpoint.AutoscalingLimitMinCu, `The minimum number of Compute Units.`) + cmd.Flags().BoolVar(&updateDatabaseEndpointReq.DatabaseEndpoint.Disabled, "disabled", updateDatabaseEndpointReq.DatabaseEndpoint.Disabled, `Whether to restrict connections to the compute endpoint.`) + cmd.Flags().StringVar(&updateDatabaseEndpointReq.DatabaseEndpoint.EndpointId, "endpoint-id", updateDatabaseEndpointReq.DatabaseEndpoint.EndpointId, ``) + cmd.Flags().Var(&updateDatabaseEndpointReq.DatabaseEndpoint.PoolerMode, "pooler-mode", `Supported values: [TRANSACTION]`) + // TODO: complex arg: settings + cmd.Flags().StringVar(&updateDatabaseEndpointReq.DatabaseEndpoint.SuspendTimeoutDuration, "suspend-timeout-duration", updateDatabaseEndpointReq.DatabaseEndpoint.SuspendTimeoutDuration, `Duration of inactivity after which the compute endpoint is automatically suspended.`) + cmd.Flags().Var(&updateDatabaseEndpointReq.DatabaseEndpoint.Type, "type", `NOTE: if want type to default to some value set the server then an effective_type field OR make this field REQUIRED. Supported values: [READ_ONLY, READ_WRITE]`) + + cmd.Use = "update-database-endpoint PROJECT_ID BRANCH_ID ENDPOINT_ID UPDATE_MASK" + cmd.Short = `Update a Database Endpoint.` + cmd.Long = `Update a Database Endpoint. + + Update a Database Endpoint. TODO: should return + databricks.longrunning.Operation { + + Arguments: + PROJECT_ID: + BRANCH_ID: + ENDPOINT_ID: + UPDATE_MASK: The list of fields to update. If unspecified, all fields will be updated + when possible.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(4) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := updateDatabaseEndpointJson.Unmarshal(&updateDatabaseEndpointReq.DatabaseEndpoint) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + updateDatabaseEndpointReq.ProjectId = args[0] + updateDatabaseEndpointReq.BranchId = args[1] + updateDatabaseEndpointReq.EndpointId = args[2] + updateDatabaseEndpointReq.UpdateMask = args[3] + + response, err := w.DatabaseProject.UpdateDatabaseEndpoint(ctx, updateDatabaseEndpointReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range updateDatabaseEndpointOverrides { + fn(cmd, &updateDatabaseEndpointReq) + } + + return cmd +} + +// start update-database-project command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var updateDatabaseProjectOverrides []func( + *cobra.Command, + *database.UpdateDatabaseProjectRequest, +) + +func newUpdateDatabaseProject() *cobra.Command { + cmd := &cobra.Command{} + + var updateDatabaseProjectReq database.UpdateDatabaseProjectRequest + updateDatabaseProjectReq.DatabaseProject = database.DatabaseProject{} + var updateDatabaseProjectJson flags.JsonFlag + + cmd.Flags().Var(&updateDatabaseProjectJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&updateDatabaseProjectReq.DatabaseProject.BudgetPolicyId, "budget-policy-id", updateDatabaseProjectReq.DatabaseProject.BudgetPolicyId, `The desired budget policy to associate with the instance.`) + // TODO: array: custom_tags + // TODO: complex arg: default_endpoint_settings + cmd.Flags().StringVar(&updateDatabaseProjectReq.DatabaseProject.DisplayName, "display-name", updateDatabaseProjectReq.DatabaseProject.DisplayName, `Human-readable project name.`) + // TODO: complex arg: effective_default_endpoint_settings + // TODO: complex arg: effective_settings + cmd.Flags().StringVar(&updateDatabaseProjectReq.DatabaseProject.HistoryRetentionDuration, "history-retention-duration", updateDatabaseProjectReq.DatabaseProject.HistoryRetentionDuration, `The number of seconds to retain the shared history for point in time recovery for all branches in this project.`) + cmd.Flags().IntVar(&updateDatabaseProjectReq.DatabaseProject.PgVersion, "pg-version", updateDatabaseProjectReq.DatabaseProject.PgVersion, `The major Postgres version number.`) + cmd.Flags().StringVar(&updateDatabaseProjectReq.DatabaseProject.ProjectId, "project-id", updateDatabaseProjectReq.DatabaseProject.ProjectId, ``) + // TODO: complex arg: settings + + cmd.Use = "update-database-project PROJECT_ID UPDATE_MASK" + cmd.Short = `Update a Database Project.` + cmd.Long = `Update a Database Project. + + Arguments: + PROJECT_ID: + UPDATE_MASK: The list of fields to update. If unspecified, all fields will be updated + when possible.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := updateDatabaseProjectJson.Unmarshal(&updateDatabaseProjectReq.DatabaseProject) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + updateDatabaseProjectReq.ProjectId = args[0] + updateDatabaseProjectReq.UpdateMask = args[1] + + response, err := w.DatabaseProject.UpdateDatabaseProject(ctx, updateDatabaseProjectReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range updateDatabaseProjectOverrides { + fn(cmd, &updateDatabaseProjectReq) + } + + return cmd +} + +// end service DatabaseProject diff --git a/cmd/workspace/database/database.go b/cmd/workspace/database/database.go index 6ce0723659..90671fc135 100755 --- a/cmd/workspace/database/database.go +++ b/cmd/workspace/database/database.go @@ -41,6 +41,7 @@ func New() *cobra.Command { cmd.AddCommand(newDeleteDatabaseInstanceRole()) cmd.AddCommand(newDeleteDatabaseTable()) cmd.AddCommand(newDeleteSyncedDatabaseTable()) + cmd.AddCommand(newFailoverDatabaseInstance()) cmd.AddCommand(newFindDatabaseInstanceByUid()) cmd.AddCommand(newGenerateDatabaseCredential()) cmd.AddCommand(newGetDatabaseCatalog()) @@ -54,6 +55,7 @@ func New() *cobra.Command { cmd.AddCommand(newListSyncedDatabaseTables()) cmd.AddCommand(newUpdateDatabaseCatalog()) cmd.AddCommand(newUpdateDatabaseInstance()) + cmd.AddCommand(newUpdateDatabaseInstanceRole()) cmd.AddCommand(newUpdateSyncedDatabaseTable()) // Apply optional overrides to this command. @@ -83,6 +85,8 @@ func newCreateDatabaseCatalog() *cobra.Command { cmd.Flags().Var(&createDatabaseCatalogJson, "json", `either inline JSON string or @path/to/file.json with request body`) cmd.Flags().BoolVar(&createDatabaseCatalogReq.Catalog.CreateDatabaseIfNotExists, "create-database-if-not-exists", createDatabaseCatalogReq.Catalog.CreateDatabaseIfNotExists, ``) + cmd.Flags().StringVar(&createDatabaseCatalogReq.Catalog.DatabaseBranchId, "database-branch-id", createDatabaseCatalogReq.Catalog.DatabaseBranchId, `The branch_id of the database branch associated with the catalog.`) + cmd.Flags().StringVar(&createDatabaseCatalogReq.Catalog.DatabaseProjectId, "database-project-id", createDatabaseCatalogReq.Catalog.DatabaseProjectId, `The project_id of the database project associated with the catalog.`) cmd.Use = "create-database-catalog NAME DATABASE_INSTANCE_NAME DATABASE_NAME" cmd.Short = `Create a Database Catalog.` @@ -179,12 +183,15 @@ func newCreateDatabaseInstance() *cobra.Command { cmd.Flags().StringVar(&createDatabaseInstanceReq.DatabaseInstance.Capacity, "capacity", createDatabaseInstanceReq.DatabaseInstance.Capacity, `The sku of the instance.`) // TODO: array: child_instance_refs + // TODO: array: custom_tags + // TODO: array: effective_custom_tags cmd.Flags().BoolVar(&createDatabaseInstanceReq.DatabaseInstance.EnablePgNativeLogin, "enable-pg-native-login", createDatabaseInstanceReq.DatabaseInstance.EnablePgNativeLogin, `Whether to enable PG native password login on the instance.`) cmd.Flags().BoolVar(&createDatabaseInstanceReq.DatabaseInstance.EnableReadableSecondaries, "enable-readable-secondaries", createDatabaseInstanceReq.DatabaseInstance.EnableReadableSecondaries, `Whether to enable secondaries to serve read-only traffic.`) cmd.Flags().IntVar(&createDatabaseInstanceReq.DatabaseInstance.NodeCount, "node-count", createDatabaseInstanceReq.DatabaseInstance.NodeCount, `The number of nodes in the instance, composed of 1 primary and 0 or more secondaries.`) // TODO: complex arg: parent_instance_ref cmd.Flags().IntVar(&createDatabaseInstanceReq.DatabaseInstance.RetentionWindowInDays, "retention-window-in-days", createDatabaseInstanceReq.DatabaseInstance.RetentionWindowInDays, `The retention window for the instance.`) cmd.Flags().BoolVar(&createDatabaseInstanceReq.DatabaseInstance.Stopped, "stopped", createDatabaseInstanceReq.DatabaseInstance.Stopped, `Whether to stop the instance.`) + cmd.Flags().StringVar(&createDatabaseInstanceReq.DatabaseInstance.UsagePolicyId, "usage-policy-id", createDatabaseInstanceReq.DatabaseInstance.UsagePolicyId, `The desired usage policy to associate with the instance.`) cmd.Use = "create-database-instance NAME" cmd.Short = `Create a Database Instance.` @@ -278,14 +285,21 @@ func newCreateDatabaseInstanceRole() *cobra.Command { cmd.Flags().Var(&createDatabaseInstanceRoleJson, "json", `either inline JSON string or @path/to/file.json with request body`) + cmd.Flags().StringVar(&createDatabaseInstanceRoleReq.DatabaseInstanceName, "database-instance-name", createDatabaseInstanceRoleReq.DatabaseInstanceName, ``) // TODO: complex arg: attributes + // TODO: complex arg: effective_attributes cmd.Flags().Var(&createDatabaseInstanceRoleReq.DatabaseInstanceRole.IdentityType, "identity-type", `The type of the role. Supported values: [GROUP, PG_ONLY, SERVICE_PRINCIPAL, USER]`) + cmd.Flags().StringVar(&createDatabaseInstanceRoleReq.DatabaseInstanceRole.InstanceName, "instance-name", createDatabaseInstanceRoleReq.DatabaseInstanceRole.InstanceName, ``) cmd.Flags().Var(&createDatabaseInstanceRoleReq.DatabaseInstanceRole.MembershipRole, "membership-role", `An enum value for a standard role that this role is a member of. Supported values: [DATABRICKS_SUPERUSER]`) - cmd.Flags().StringVar(&createDatabaseInstanceRoleReq.DatabaseInstanceRole.Name, "name", createDatabaseInstanceRoleReq.DatabaseInstanceRole.Name, `The name of the role.`) - cmd.Use = "create-database-instance-role INSTANCE_NAME" + cmd.Use = "create-database-instance-role INSTANCE_NAME NAME" cmd.Short = `Create a role for a Database Instance.` - cmd.Long = `Create a role for a Database Instance.` + cmd.Long = `Create a role for a Database Instance. + + Arguments: + INSTANCE_NAME: + NAME: The name of the role. This is the unique identifier for the role in an + instance.` // This command is being previewed; hide from help output. cmd.Hidden = true @@ -293,7 +307,14 @@ func newCreateDatabaseInstanceRole() *cobra.Command { cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { - check := root.ExactArgs(1) + if cmd.Flags().Changed("json") { + err := root.ExactArgs(1)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, provide only INSTANCE_NAME as positional arguments. Provide 'name' in your JSON input") + } + return nil + } + check := root.ExactArgs(2) return check(cmd, args) } @@ -315,6 +336,9 @@ func newCreateDatabaseInstanceRole() *cobra.Command { } } createDatabaseInstanceRoleReq.InstanceName = args[0] + if !cmd.Flags().Changed("json") { + createDatabaseInstanceRoleReq.DatabaseInstanceRole.Name = args[1] + } response, err := w.Database.CreateDatabaseInstanceRole(ctx, createDatabaseInstanceRoleReq) if err != nil { @@ -440,7 +464,9 @@ func newCreateSyncedDatabaseTable() *cobra.Command { cmd.Flags().Var(&createSyncedDatabaseTableJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: data_synchronization_status + cmd.Flags().StringVar(&createSyncedDatabaseTableReq.SyncedTable.DatabaseBranchId, "database-branch-id", createSyncedDatabaseTableReq.SyncedTable.DatabaseBranchId, `The branch_id of the database branch associated with the table.`) cmd.Flags().StringVar(&createSyncedDatabaseTableReq.SyncedTable.DatabaseInstanceName, "database-instance-name", createSyncedDatabaseTableReq.SyncedTable.DatabaseInstanceName, `Name of the target database instance.`) + cmd.Flags().StringVar(&createSyncedDatabaseTableReq.SyncedTable.DatabaseProjectId, "database-project-id", createSyncedDatabaseTableReq.SyncedTable.DatabaseProjectId, `The project_id of the database project associated with the table.`) cmd.Flags().StringVar(&createSyncedDatabaseTableReq.SyncedTable.LogicalDatabaseName, "logical-database-name", createSyncedDatabaseTableReq.SyncedTable.LogicalDatabaseName, `Target Postgres database object (logical database) name for this table.`) // TODO: complex arg: spec @@ -775,6 +801,77 @@ func newDeleteSyncedDatabaseTable() *cobra.Command { return cmd } +// start failover-database-instance command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var failoverDatabaseInstanceOverrides []func( + *cobra.Command, + *database.FailoverDatabaseInstanceRequest, +) + +func newFailoverDatabaseInstance() *cobra.Command { + cmd := &cobra.Command{} + + var failoverDatabaseInstanceReq database.FailoverDatabaseInstanceRequest + var failoverDatabaseInstanceJson flags.JsonFlag + + cmd.Flags().Var(&failoverDatabaseInstanceJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&failoverDatabaseInstanceReq.FailoverTargetDatabaseInstanceName, "failover-target-database-instance-name", failoverDatabaseInstanceReq.FailoverTargetDatabaseInstanceName, ``) + + cmd.Use = "failover-database-instance NAME" + cmd.Short = `Failover the primary node of a Database Instance to a secondary.` + cmd.Long = `Failover the primary node of a Database Instance to a secondary. + + Arguments: + NAME: Name of the instance to failover.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := failoverDatabaseInstanceJson.Unmarshal(&failoverDatabaseInstanceReq) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + failoverDatabaseInstanceReq.Name = args[0] + + response, err := w.Database.FailoverDatabaseInstance(ctx, failoverDatabaseInstanceReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range failoverDatabaseInstanceOverrides { + fn(cmd, &failoverDatabaseInstanceReq) + } + + return cmd +} + // start find-database-instance-by-uid command // Slice with functions to override default command behavior. @@ -1405,6 +1502,8 @@ func newUpdateDatabaseCatalog() *cobra.Command { cmd.Flags().Var(&updateDatabaseCatalogJson, "json", `either inline JSON string or @path/to/file.json with request body`) cmd.Flags().BoolVar(&updateDatabaseCatalogReq.DatabaseCatalog.CreateDatabaseIfNotExists, "create-database-if-not-exists", updateDatabaseCatalogReq.DatabaseCatalog.CreateDatabaseIfNotExists, ``) + cmd.Flags().StringVar(&updateDatabaseCatalogReq.DatabaseCatalog.DatabaseBranchId, "database-branch-id", updateDatabaseCatalogReq.DatabaseCatalog.DatabaseBranchId, `The branch_id of the database branch associated with the catalog.`) + cmd.Flags().StringVar(&updateDatabaseCatalogReq.DatabaseCatalog.DatabaseProjectId, "database-project-id", updateDatabaseCatalogReq.DatabaseCatalog.DatabaseProjectId, `The project_id of the database project associated with the catalog.`) cmd.Use = "update-database-catalog NAME UPDATE_MASK DATABASE_INSTANCE_NAME DATABASE_NAME" cmd.Short = `Update a Database Catalog.` @@ -1500,12 +1599,15 @@ func newUpdateDatabaseInstance() *cobra.Command { cmd.Flags().StringVar(&updateDatabaseInstanceReq.DatabaseInstance.Capacity, "capacity", updateDatabaseInstanceReq.DatabaseInstance.Capacity, `The sku of the instance.`) // TODO: array: child_instance_refs + // TODO: array: custom_tags + // TODO: array: effective_custom_tags cmd.Flags().BoolVar(&updateDatabaseInstanceReq.DatabaseInstance.EnablePgNativeLogin, "enable-pg-native-login", updateDatabaseInstanceReq.DatabaseInstance.EnablePgNativeLogin, `Whether to enable PG native password login on the instance.`) cmd.Flags().BoolVar(&updateDatabaseInstanceReq.DatabaseInstance.EnableReadableSecondaries, "enable-readable-secondaries", updateDatabaseInstanceReq.DatabaseInstance.EnableReadableSecondaries, `Whether to enable secondaries to serve read-only traffic.`) cmd.Flags().IntVar(&updateDatabaseInstanceReq.DatabaseInstance.NodeCount, "node-count", updateDatabaseInstanceReq.DatabaseInstance.NodeCount, `The number of nodes in the instance, composed of 1 primary and 0 or more secondaries.`) // TODO: complex arg: parent_instance_ref cmd.Flags().IntVar(&updateDatabaseInstanceReq.DatabaseInstance.RetentionWindowInDays, "retention-window-in-days", updateDatabaseInstanceReq.DatabaseInstance.RetentionWindowInDays, `The retention window for the instance.`) cmd.Flags().BoolVar(&updateDatabaseInstanceReq.DatabaseInstance.Stopped, "stopped", updateDatabaseInstanceReq.DatabaseInstance.Stopped, `Whether to stop the instance.`) + cmd.Flags().StringVar(&updateDatabaseInstanceReq.DatabaseInstance.UsagePolicyId, "usage-policy-id", updateDatabaseInstanceReq.DatabaseInstance.UsagePolicyId, `The desired usage policy to associate with the instance.`) cmd.Use = "update-database-instance NAME UPDATE_MASK" cmd.Short = `Update a Database Instance.` @@ -1563,6 +1665,86 @@ func newUpdateDatabaseInstance() *cobra.Command { return cmd } +// start update-database-instance-role command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var updateDatabaseInstanceRoleOverrides []func( + *cobra.Command, + *database.UpdateDatabaseInstanceRoleRequest, +) + +func newUpdateDatabaseInstanceRole() *cobra.Command { + cmd := &cobra.Command{} + + var updateDatabaseInstanceRoleReq database.UpdateDatabaseInstanceRoleRequest + updateDatabaseInstanceRoleReq.DatabaseInstanceRole = database.DatabaseInstanceRole{} + var updateDatabaseInstanceRoleJson flags.JsonFlag + + cmd.Flags().Var(&updateDatabaseInstanceRoleJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&updateDatabaseInstanceRoleReq.DatabaseInstanceName, "database-instance-name", updateDatabaseInstanceRoleReq.DatabaseInstanceName, ``) + // TODO: complex arg: attributes + // TODO: complex arg: effective_attributes + cmd.Flags().Var(&updateDatabaseInstanceRoleReq.DatabaseInstanceRole.IdentityType, "identity-type", `The type of the role. Supported values: [GROUP, PG_ONLY, SERVICE_PRINCIPAL, USER]`) + cmd.Flags().StringVar(&updateDatabaseInstanceRoleReq.DatabaseInstanceRole.InstanceName, "instance-name", updateDatabaseInstanceRoleReq.DatabaseInstanceRole.InstanceName, ``) + cmd.Flags().Var(&updateDatabaseInstanceRoleReq.DatabaseInstanceRole.MembershipRole, "membership-role", `An enum value for a standard role that this role is a member of. Supported values: [DATABRICKS_SUPERUSER]`) + + cmd.Use = "update-database-instance-role INSTANCE_NAME NAME" + cmd.Short = `Update a role for a Database Instance.` + cmd.Long = `Update a role for a Database Instance. + + Arguments: + INSTANCE_NAME: + NAME: The name of the role. This is the unique identifier for the role in an + instance.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := updateDatabaseInstanceRoleJson.Unmarshal(&updateDatabaseInstanceRoleReq.DatabaseInstanceRole) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + updateDatabaseInstanceRoleReq.InstanceName = args[0] + updateDatabaseInstanceRoleReq.Name = args[1] + + response, err := w.Database.UpdateDatabaseInstanceRole(ctx, updateDatabaseInstanceRoleReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range updateDatabaseInstanceRoleOverrides { + fn(cmd, &updateDatabaseInstanceRoleReq) + } + + return cmd +} + // start update-synced-database-table command // Slice with functions to override default command behavior. @@ -1582,7 +1764,9 @@ func newUpdateSyncedDatabaseTable() *cobra.Command { cmd.Flags().Var(&updateSyncedDatabaseTableJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: data_synchronization_status + cmd.Flags().StringVar(&updateSyncedDatabaseTableReq.SyncedTable.DatabaseBranchId, "database-branch-id", updateSyncedDatabaseTableReq.SyncedTable.DatabaseBranchId, `The branch_id of the database branch associated with the table.`) cmd.Flags().StringVar(&updateSyncedDatabaseTableReq.SyncedTable.DatabaseInstanceName, "database-instance-name", updateSyncedDatabaseTableReq.SyncedTable.DatabaseInstanceName, `Name of the target database instance.`) + cmd.Flags().StringVar(&updateSyncedDatabaseTableReq.SyncedTable.DatabaseProjectId, "database-project-id", updateSyncedDatabaseTableReq.SyncedTable.DatabaseProjectId, `The project_id of the database project associated with the table.`) cmd.Flags().StringVar(&updateSyncedDatabaseTableReq.SyncedTable.LogicalDatabaseName, "logical-database-name", updateSyncedDatabaseTableReq.SyncedTable.LogicalDatabaseName, `Target Postgres database object (logical database) name for this table.`) // TODO: complex arg: spec diff --git a/cmd/workspace/experiments/experiments.go b/cmd/workspace/experiments/experiments.go index 56c3fd1374..c648a60a6d 100755 --- a/cmd/workspace/experiments/experiments.go +++ b/cmd/workspace/experiments/experiments.go @@ -52,6 +52,7 @@ func New() *cobra.Command { cmd.AddCommand(newGetExperiment()) cmd.AddCommand(newGetHistory()) cmd.AddCommand(newGetLoggedModel()) + cmd.AddCommand(newGetLoggedModels()) cmd.AddCommand(newGetPermissionLevels()) cmd.AddCommand(newGetPermissions()) cmd.AddCommand(newGetRun()) @@ -1102,6 +1103,59 @@ func newGetLoggedModel() *cobra.Command { return cmd } +// start get-logged-models command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var getLoggedModelsOverrides []func( + *cobra.Command, + *ml.GetLoggedModelsRequest, +) + +func newGetLoggedModels() *cobra.Command { + cmd := &cobra.Command{} + + var getLoggedModelsReq ml.GetLoggedModelsRequest + + // TODO: array: model_ids + + cmd.Use = "get-logged-models" + cmd.Short = `Get a batch of logged models.` + cmd.Long = `Get a batch of logged models. + + Batch endpoint for getting logged models from a list of model IDs` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(0) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + response, err := w.Experiments.GetLoggedModels(ctx, getLoggedModelsReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range getLoggedModelsOverrides { + fn(cmd, &getLoggedModelsReq) + } + + return cmd +} + // start get-permission-levels command // Slice with functions to override default command behavior. diff --git a/cmd/workspace/external-locations/external-locations.go b/cmd/workspace/external-locations/external-locations.go index a0db1aeaa4..0d10c3b243 100755 --- a/cmd/workspace/external-locations/external-locations.go +++ b/cmd/workspace/external-locations/external-locations.go @@ -288,6 +288,7 @@ func newList() *cobra.Command { var listReq catalog.ListExternalLocationsRequest cmd.Flags().BoolVar(&listReq.IncludeBrowse, "include-browse", listReq.IncludeBrowse, `Whether to include external locations in the response for which the principal can only access selective metadata for.`) + cmd.Flags().BoolVar(&listReq.IncludeUnbound, "include-unbound", listReq.IncludeUnbound, `Whether to include external locations not bound to the workspace.`) cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Maximum number of external locations to return.`) cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Opaque pagination token to go to next page based on previous query.`) diff --git a/cmd/workspace/external-metadata/external-metadata.go b/cmd/workspace/external-metadata/external-metadata.go index fc9c2c56f8..d11a36387c 100755 --- a/cmd/workspace/external-metadata/external-metadata.go +++ b/cmd/workspace/external-metadata/external-metadata.go @@ -105,6 +105,7 @@ func newCreateExternalMetadata() *cobra.Command { SAP, SERVICENOW, SNOWFLAKE, + STREAM_NATIVE, TABLEAU, TERADATA, WORKDAY, @@ -407,6 +408,7 @@ func newUpdateExternalMetadata() *cobra.Command { SAP, SERVICENOW, SNOWFLAKE, + STREAM_NATIVE, TABLEAU, TERADATA, WORKDAY, diff --git a/cmd/workspace/functions/functions.go b/cmd/workspace/functions/functions.go index 057a43547e..850631ac6f 100755 --- a/cmd/workspace/functions/functions.go +++ b/cmd/workspace/functions/functions.go @@ -148,7 +148,7 @@ func newDelete() *cobra.Command { Arguments: NAME: The fully-qualified name of the function (of the form - __catalog_name__.__schema_name__.__function__name__).` + __catalog_name__.__schema_name__.__function__name__) .` cmd.Annotations = make(map[string]string) @@ -165,14 +165,14 @@ func newDelete() *cobra.Command { if err != nil { return fmt.Errorf("failed to load names for Functions drop-down. Please manually specify required arguments. Original error: %w", err) } - id, err := cmdio.Select(ctx, names, "The fully-qualified name of the function (of the form __catalog_name__.__schema_name__.__function__name__)") + id, err := cmdio.Select(ctx, names, "The fully-qualified name of the function (of the form __catalog_name__.__schema_name__.__function__name__) ") if err != nil { return err } args = append(args, id) } if len(args) != 1 { - return fmt.Errorf("expected to have the fully-qualified name of the function (of the form __catalog_name__.__schema_name__.__function__name__)") + return fmt.Errorf("expected to have the fully-qualified name of the function (of the form __catalog_name__.__schema_name__.__function__name__) ") } deleteReq.Name = args[0] @@ -354,7 +354,7 @@ func newUpdate() *cobra.Command { cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateReq.Owner, "owner", updateReq.Owner, `Username of current owner of function.`) + cmd.Flags().StringVar(&updateReq.Owner, "owner", updateReq.Owner, `Username of current owner of the function.`) cmd.Use = "update NAME" cmd.Short = `Update a function.` diff --git a/cmd/workspace/genie/genie.go b/cmd/workspace/genie/genie.go index d2a402342b..fa6f4ac6e8 100755 --- a/cmd/workspace/genie/genie.go +++ b/cmd/workspace/genie/genie.go @@ -36,10 +36,13 @@ func New() *cobra.Command { // Add methods cmd.AddCommand(newCreateMessage()) + cmd.AddCommand(newCreateSpace()) cmd.AddCommand(newDeleteConversation()) cmd.AddCommand(newDeleteConversationMessage()) cmd.AddCommand(newExecuteMessageAttachmentQuery()) cmd.AddCommand(newExecuteMessageQuery()) + cmd.AddCommand(newGenerateDownloadFullQueryResult()) + cmd.AddCommand(newGetDownloadFullQueryResult()) cmd.AddCommand(newGetMessage()) cmd.AddCommand(newGetMessageAttachmentQueryResult()) cmd.AddCommand(newGetMessageQueryResult()) @@ -51,6 +54,7 @@ func New() *cobra.Command { cmd.AddCommand(newSendMessageFeedback()) cmd.AddCommand(newStartConversation()) cmd.AddCommand(newTrashSpace()) + cmd.AddCommand(newUpdateSpace()) // Apply optional overrides to this command. for _, fn := range cmdOverrides { @@ -165,6 +169,94 @@ func newCreateMessage() *cobra.Command { return cmd } +// start create-space command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var createSpaceOverrides []func( + *cobra.Command, + *dashboards.GenieCreateSpaceRequest, +) + +func newCreateSpace() *cobra.Command { + cmd := &cobra.Command{} + + var createSpaceReq dashboards.GenieCreateSpaceRequest + var createSpaceJson flags.JsonFlag + + cmd.Flags().Var(&createSpaceJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&createSpaceReq.Description, "description", createSpaceReq.Description, `Optional description.`) + cmd.Flags().StringVar(&createSpaceReq.ParentPath, "parent-path", createSpaceReq.ParentPath, `Parent folder path where the space will be registered.`) + cmd.Flags().StringVar(&createSpaceReq.Title, "title", createSpaceReq.Title, `Optional title override.`) + + cmd.Use = "create-space WAREHOUSE_ID SERIALIZED_SPACE" + cmd.Short = `Create Genie Space.` + cmd.Long = `Create Genie Space. + + Creates a Genie space from a serialized payload. + + Arguments: + WAREHOUSE_ID: Warehouse to associate with the new space + SERIALIZED_SPACE: Serialized export model for the space contents` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + if cmd.Flags().Changed("json") { + err := root.ExactArgs(0)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'warehouse_id', 'serialized_space' in your JSON input") + } + return nil + } + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := createSpaceJson.Unmarshal(&createSpaceReq) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + if !cmd.Flags().Changed("json") { + createSpaceReq.WarehouseId = args[0] + } + if !cmd.Flags().Changed("json") { + createSpaceReq.SerializedSpace = args[1] + } + + response, err := w.Genie.CreateSpace(ctx, createSpaceReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range createSpaceOverrides { + fn(cmd, &createSpaceReq) + } + + return cmd +} + // start delete-conversation command // Slice with functions to override default command behavior. @@ -410,6 +502,148 @@ func newExecuteMessageQuery() *cobra.Command { return cmd } +// start generate-download-full-query-result command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var generateDownloadFullQueryResultOverrides []func( + *cobra.Command, + *dashboards.GenieGenerateDownloadFullQueryResultRequest, +) + +func newGenerateDownloadFullQueryResult() *cobra.Command { + cmd := &cobra.Command{} + + var generateDownloadFullQueryResultReq dashboards.GenieGenerateDownloadFullQueryResultRequest + + cmd.Use = "generate-download-full-query-result SPACE_ID CONVERSATION_ID MESSAGE_ID ATTACHMENT_ID" + cmd.Short = `Generate full query result download.` + cmd.Long = `Generate full query result download. + + Initiates a new SQL execution and returns a download_id that you can use to + track the progress of the download. The query result is stored in an external + link and can be retrieved using the [Get Download Full Query + Result](:method:genie/getdownloadfullqueryresult) API. Warning: Databricks + strongly recommends that you protect the URLs that are returned by the + EXTERNAL_LINKS disposition. See [Execute + Statement](:method:statementexecution/executestatement) for more details. + + Arguments: + SPACE_ID: Genie space ID + CONVERSATION_ID: Conversation ID + MESSAGE_ID: Message ID + ATTACHMENT_ID: Attachment ID` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(4) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + generateDownloadFullQueryResultReq.SpaceId = args[0] + generateDownloadFullQueryResultReq.ConversationId = args[1] + generateDownloadFullQueryResultReq.MessageId = args[2] + generateDownloadFullQueryResultReq.AttachmentId = args[3] + + response, err := w.Genie.GenerateDownloadFullQueryResult(ctx, generateDownloadFullQueryResultReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range generateDownloadFullQueryResultOverrides { + fn(cmd, &generateDownloadFullQueryResultReq) + } + + return cmd +} + +// start get-download-full-query-result command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var getDownloadFullQueryResultOverrides []func( + *cobra.Command, + *dashboards.GenieGetDownloadFullQueryResultRequest, +) + +func newGetDownloadFullQueryResult() *cobra.Command { + cmd := &cobra.Command{} + + var getDownloadFullQueryResultReq dashboards.GenieGetDownloadFullQueryResultRequest + + cmd.Use = "get-download-full-query-result SPACE_ID CONVERSATION_ID MESSAGE_ID ATTACHMENT_ID DOWNLOAD_ID" + cmd.Short = `Get download full query result.` + cmd.Long = `Get download full query result. + + After [Generating a Full Query Result + Download](:method:genie/getdownloadfullqueryresult) and successfully receiving + a download_id, use this API to poll the download progress. When the download + is complete, the API returns one or more external links to the query result + files. Warning: Databricks strongly recommends that you protect the URLs that + are returned by the EXTERNAL_LINKS disposition. You must not set an + Authorization header in download requests. When using the EXTERNAL_LINKS + disposition, Databricks returns presigned URLs that grant temporary access to + data. See [Execute Statement](:method:statementexecution/executestatement) for + more details. + + Arguments: + SPACE_ID: Genie space ID + CONVERSATION_ID: Conversation ID + MESSAGE_ID: Message ID + ATTACHMENT_ID: Attachment ID + DOWNLOAD_ID: Download ID. This ID is provided by the [Generate Download + endpoint](:method:genie/generateDownloadFullQueryResult)` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(5) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + getDownloadFullQueryResultReq.SpaceId = args[0] + getDownloadFullQueryResultReq.ConversationId = args[1] + getDownloadFullQueryResultReq.MessageId = args[2] + getDownloadFullQueryResultReq.AttachmentId = args[3] + getDownloadFullQueryResultReq.DownloadId = args[4] + + response, err := w.Genie.GetDownloadFullQueryResult(ctx, getDownloadFullQueryResultReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range getDownloadFullQueryResultOverrides { + fn(cmd, &getDownloadFullQueryResultReq) + } + + return cmd +} + // start get-message command // Slice with functions to override default command behavior. @@ -914,6 +1148,8 @@ func newSendMessageFeedback() *cobra.Command { cmd.Flags().Var(&sendMessageFeedbackJson, "json", `either inline JSON string or @path/to/file.json with request body`) + cmd.Flags().StringVar(&sendMessageFeedbackReq.Comment, "comment", sendMessageFeedbackReq.Comment, `Optional text feedback that will be stored as a comment.`) + cmd.Use = "send-message-feedback SPACE_ID CONVERSATION_ID MESSAGE_ID RATING" cmd.Short = `Send message feedback.` cmd.Long = `Send message feedback. @@ -1145,4 +1381,80 @@ func newTrashSpace() *cobra.Command { return cmd } +// start update-space command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var updateSpaceOverrides []func( + *cobra.Command, + *dashboards.GenieUpdateSpaceRequest, +) + +func newUpdateSpace() *cobra.Command { + cmd := &cobra.Command{} + + var updateSpaceReq dashboards.GenieUpdateSpaceRequest + var updateSpaceJson flags.JsonFlag + + cmd.Flags().Var(&updateSpaceJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&updateSpaceReq.Description, "description", updateSpaceReq.Description, `Optional description.`) + cmd.Flags().StringVar(&updateSpaceReq.SerializedSpace, "serialized-space", updateSpaceReq.SerializedSpace, `Serialized export model for the space contents (full replacement).`) + cmd.Flags().StringVar(&updateSpaceReq.Title, "title", updateSpaceReq.Title, `Optional title override.`) + cmd.Flags().StringVar(&updateSpaceReq.WarehouseId, "warehouse-id", updateSpaceReq.WarehouseId, `Optional warehouse override.`) + + cmd.Use = "update-space SPACE_ID" + cmd.Short = `Update Genie Space.` + cmd.Long = `Update Genie Space. + + Updates a Genie space with a serialized payload. + + Arguments: + SPACE_ID: Genie space ID` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := updateSpaceJson.Unmarshal(&updateSpaceReq) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + updateSpaceReq.SpaceId = args[0] + + response, err := w.Genie.UpdateSpace(ctx, updateSpaceReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range updateSpaceOverrides { + fn(cmd, &updateSpaceReq) + } + + return cmd +} + // end service Genie diff --git a/cmd/workspace/grants/grants.go b/cmd/workspace/grants/grants.go index 3aabdae525..d4344a0bd0 100755 --- a/cmd/workspace/grants/grants.go +++ b/cmd/workspace/grants/grants.go @@ -64,6 +64,7 @@ func newGet() *cobra.Command { var getReq catalog.GetGrantRequest + cmd.Flags().BoolVar(&getReq.IncludeDeletedPrincipals, "include-deleted-principals", getReq.IncludeDeletedPrincipals, `Optional.`) cmd.Flags().IntVar(&getReq.MaxResults, "max-results", getReq.MaxResults, `Specifies the maximum number of privileges to return (page length).`) cmd.Flags().StringVar(&getReq.PageToken, "page-token", getReq.PageToken, `Opaque pagination token to go to next page based on previous query.`) cmd.Flags().StringVar(&getReq.Principal, "principal", getReq.Principal, `If provided, only the permissions for the specified principal (user or group) are returned.`) diff --git a/cmd/workspace/instance-pools/instance-pools.go b/cmd/workspace/instance-pools/instance-pools.go index 7e6d69b320..717e67b0e5 100755 --- a/cmd/workspace/instance-pools/instance-pools.go +++ b/cmd/workspace/instance-pools/instance-pools.go @@ -86,11 +86,13 @@ func newCreate() *cobra.Command { // TODO: complex arg: azure_attributes // TODO: map via StringToStringVar: custom_tags // TODO: complex arg: disk_spec + cmd.Flags().BoolVar(&createReq.EnableAutoAlternateNodeTypes, "enable-auto-alternate-node-types", createReq.EnableAutoAlternateNodeTypes, `For pools with node type flexibility (Fleet-V2), whether auto generated alternate node type ids are enabled.`) cmd.Flags().BoolVar(&createReq.EnableElasticDisk, "enable-elastic-disk", createReq.EnableElasticDisk, `Autoscaling Local Storage: when enabled, this instances in this pool will dynamically acquire additional disk space when its Spark workers are running low on disk space.`) // TODO: complex arg: gcp_attributes cmd.Flags().IntVar(&createReq.IdleInstanceAutoterminationMinutes, "idle-instance-autotermination-minutes", createReq.IdleInstanceAutoterminationMinutes, `Automatically terminates the extra instances in the pool cache after they are inactive for this time in minutes if min_idle_instances requirement is already met.`) cmd.Flags().IntVar(&createReq.MaxCapacity, "max-capacity", createReq.MaxCapacity, `Maximum number of outstanding instances to keep in the pool, including both instances used by clusters and idle instances.`) cmd.Flags().IntVar(&createReq.MinIdleInstances, "min-idle-instances", createReq.MinIdleInstances, `Minimum number of idle instances to keep in the instance pool.`) + // TODO: complex arg: node_type_flexibility // TODO: array: preloaded_docker_images // TODO: array: preloaded_spark_versions cmd.Flags().IntVar(&createReq.RemoteDiskThroughput, "remote-disk-throughput", createReq.RemoteDiskThroughput, `If set, what the configurable throughput (in Mb/s) for the remote disk is.`) @@ -282,9 +284,11 @@ func newEdit() *cobra.Command { cmd.Flags().Var(&editJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: map via StringToStringVar: custom_tags + cmd.Flags().BoolVar(&editReq.EnableAutoAlternateNodeTypes, "enable-auto-alternate-node-types", editReq.EnableAutoAlternateNodeTypes, `For pools with node type flexibility (Fleet-V2), whether auto generated alternate node type ids are enabled.`) cmd.Flags().IntVar(&editReq.IdleInstanceAutoterminationMinutes, "idle-instance-autotermination-minutes", editReq.IdleInstanceAutoterminationMinutes, `Automatically terminates the extra instances in the pool cache after they are inactive for this time in minutes if min_idle_instances requirement is already met.`) cmd.Flags().IntVar(&editReq.MaxCapacity, "max-capacity", editReq.MaxCapacity, `Maximum number of outstanding instances to keep in the pool, including both instances used by clusters and idle instances.`) cmd.Flags().IntVar(&editReq.MinIdleInstances, "min-idle-instances", editReq.MinIdleInstances, `Minimum number of idle instances to keep in the instance pool.`) + // TODO: complex arg: node_type_flexibility cmd.Flags().IntVar(&editReq.RemoteDiskThroughput, "remote-disk-throughput", editReq.RemoteDiskThroughput, `If set, what the configurable throughput (in Mb/s) for the remote disk is.`) cmd.Flags().IntVar(&editReq.TotalInitialRemoteDiskSize, "total-initial-remote-disk-size", editReq.TotalInitialRemoteDiskSize, `If set, what the total initial volume size (in GB) of the remote disks should be.`) diff --git a/cmd/workspace/lakeview-embedded/lakeview-embedded.go b/cmd/workspace/lakeview-embedded/lakeview-embedded.go index 5700d23645..b37d454624 100755 --- a/cmd/workspace/lakeview-embedded/lakeview-embedded.go +++ b/cmd/workspace/lakeview-embedded/lakeview-embedded.go @@ -27,6 +27,7 @@ func New() *cobra.Command { } // Add methods + cmd.AddCommand(newGetPublishedDashboardEmbedded()) cmd.AddCommand(newGetPublishedDashboardTokenInfo()) // Apply optional overrides to this command. @@ -37,6 +38,62 @@ func New() *cobra.Command { return cmd } +// start get-published-dashboard-embedded command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var getPublishedDashboardEmbeddedOverrides []func( + *cobra.Command, + *dashboards.GetPublishedDashboardEmbeddedRequest, +) + +func newGetPublishedDashboardEmbedded() *cobra.Command { + cmd := &cobra.Command{} + + var getPublishedDashboardEmbeddedReq dashboards.GetPublishedDashboardEmbeddedRequest + + cmd.Use = "get-published-dashboard-embedded DASHBOARD_ID" + cmd.Short = `Read a published dashboard in an embedded ui.` + cmd.Long = `Read a published dashboard in an embedded ui. + + Get the current published dashboard within an embedded context. + + Arguments: + DASHBOARD_ID: UUID identifying the published dashboard.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + getPublishedDashboardEmbeddedReq.DashboardId = args[0] + + err = w.LakeviewEmbedded.GetPublishedDashboardEmbedded(ctx, getPublishedDashboardEmbeddedReq) + if err != nil { + return err + } + return nil + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range getPublishedDashboardEmbeddedOverrides { + fn(cmd, &getPublishedDashboardEmbeddedReq) + } + + return cmd +} + // start get-published-dashboard-token-info command // Slice with functions to override default command behavior. diff --git a/cmd/workspace/libraries/libraries.go b/cmd/workspace/libraries/libraries.go index 8599ba0057..98b114e139 100755 --- a/cmd/workspace/libraries/libraries.go +++ b/cmd/workspace/libraries/libraries.go @@ -47,8 +47,15 @@ func New() *cobra.Command { // Add methods cmd.AddCommand(newAllClusterStatuses()) cmd.AddCommand(newClusterStatus()) + cmd.AddCommand(newCreateDefaultBaseEnvironment()) + cmd.AddCommand(newDeleteDefaultBaseEnvironment()) + cmd.AddCommand(newGetDefaultBaseEnvironment()) cmd.AddCommand(newInstall()) + cmd.AddCommand(newListDefaultBaseEnvironments()) + cmd.AddCommand(newRefreshDefaultBaseEnvironments()) cmd.AddCommand(newUninstall()) + cmd.AddCommand(newUpdateDefaultBaseEnvironment()) + cmd.AddCommand(newUpdateDefaultDefaultBaseEnvironment()) // Apply optional overrides to this command. for _, fn := range cmdOverrides { @@ -157,6 +164,185 @@ func newClusterStatus() *cobra.Command { return cmd } +// start create-default-base-environment command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var createDefaultBaseEnvironmentOverrides []func( + *cobra.Command, + *compute.CreateDefaultBaseEnvironmentRequest, +) + +func newCreateDefaultBaseEnvironment() *cobra.Command { + cmd := &cobra.Command{} + + var createDefaultBaseEnvironmentReq compute.CreateDefaultBaseEnvironmentRequest + var createDefaultBaseEnvironmentJson flags.JsonFlag + + cmd.Flags().Var(&createDefaultBaseEnvironmentJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&createDefaultBaseEnvironmentReq.RequestId, "request-id", createDefaultBaseEnvironmentReq.RequestId, `A unique identifier for this request.`) + + cmd.Use = "create-default-base-environment" + cmd.Short = `Create a default base environment.` + cmd.Long = `Create a default base environment. + + Create a default base environment within workspaces to define the environment + version and a list of dependencies to be used in serverless notebooks and + jobs. This process will asynchronously generate a cache to optimize dependency + resolution.` + + cmd.Annotations = make(map[string]string) + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := createDefaultBaseEnvironmentJson.Unmarshal(&createDefaultBaseEnvironmentReq) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } else { + return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") + } + + response, err := w.Libraries.CreateDefaultBaseEnvironment(ctx, createDefaultBaseEnvironmentReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range createDefaultBaseEnvironmentOverrides { + fn(cmd, &createDefaultBaseEnvironmentReq) + } + + return cmd +} + +// start delete-default-base-environment command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var deleteDefaultBaseEnvironmentOverrides []func( + *cobra.Command, + *compute.DeleteDefaultBaseEnvironmentRequest, +) + +func newDeleteDefaultBaseEnvironment() *cobra.Command { + cmd := &cobra.Command{} + + var deleteDefaultBaseEnvironmentReq compute.DeleteDefaultBaseEnvironmentRequest + + cmd.Use = "delete-default-base-environment ID" + cmd.Short = `Delete a default base environment.` + cmd.Long = `Delete a default base environment. + + Delete the default base environment given an ID. The default base environment + may be used by downstream workloads. Please ensure that the deletion is + intentional.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + deleteDefaultBaseEnvironmentReq.Id = args[0] + + err = w.Libraries.DeleteDefaultBaseEnvironment(ctx, deleteDefaultBaseEnvironmentReq) + if err != nil { + return err + } + return nil + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range deleteDefaultBaseEnvironmentOverrides { + fn(cmd, &deleteDefaultBaseEnvironmentReq) + } + + return cmd +} + +// start get-default-base-environment command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var getDefaultBaseEnvironmentOverrides []func( + *cobra.Command, + *compute.GetDefaultBaseEnvironmentRequest, +) + +func newGetDefaultBaseEnvironment() *cobra.Command { + cmd := &cobra.Command{} + + var getDefaultBaseEnvironmentReq compute.GetDefaultBaseEnvironmentRequest + + cmd.Flags().StringVar(&getDefaultBaseEnvironmentReq.TraceId, "trace-id", getDefaultBaseEnvironmentReq.TraceId, ``) + + cmd.Use = "get-default-base-environment ID" + cmd.Short = `get a default base environment.` + cmd.Long = `get a default base environment. + + Return the default base environment details for a given ID.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + getDefaultBaseEnvironmentReq.Id = args[0] + + response, err := w.Libraries.GetDefaultBaseEnvironment(ctx, getDefaultBaseEnvironmentReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range getDefaultBaseEnvironmentOverrides { + fn(cmd, &getDefaultBaseEnvironmentReq) + } + + return cmd +} + // start install command // Slice with functions to override default command behavior. @@ -222,6 +408,124 @@ func newInstall() *cobra.Command { return cmd } +// start list-default-base-environments command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var listDefaultBaseEnvironmentsOverrides []func( + *cobra.Command, + *compute.ListDefaultBaseEnvironmentsRequest, +) + +func newListDefaultBaseEnvironments() *cobra.Command { + cmd := &cobra.Command{} + + var listDefaultBaseEnvironmentsReq compute.ListDefaultBaseEnvironmentsRequest + + cmd.Flags().IntVar(&listDefaultBaseEnvironmentsReq.PageSize, "page-size", listDefaultBaseEnvironmentsReq.PageSize, ``) + cmd.Flags().StringVar(&listDefaultBaseEnvironmentsReq.PageToken, "page-token", listDefaultBaseEnvironmentsReq.PageToken, ``) + + cmd.Use = "list-default-base-environments" + cmd.Short = `List default base environments.` + cmd.Long = `List default base environments. + + List default base environments defined in the workspaces for the requested + user.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(0) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + response := w.Libraries.ListDefaultBaseEnvironments(ctx, listDefaultBaseEnvironmentsReq) + return cmdio.RenderIterator(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range listDefaultBaseEnvironmentsOverrides { + fn(cmd, &listDefaultBaseEnvironmentsReq) + } + + return cmd +} + +// start refresh-default-base-environments command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var refreshDefaultBaseEnvironmentsOverrides []func( + *cobra.Command, + *compute.RefreshDefaultBaseEnvironmentsRequest, +) + +func newRefreshDefaultBaseEnvironments() *cobra.Command { + cmd := &cobra.Command{} + + var refreshDefaultBaseEnvironmentsReq compute.RefreshDefaultBaseEnvironmentsRequest + var refreshDefaultBaseEnvironmentsJson flags.JsonFlag + + cmd.Flags().Var(&refreshDefaultBaseEnvironmentsJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Use = "refresh-default-base-environments" + cmd.Short = `.` + cmd.Long = `. + + Refresh the cached default base environments for the given IDs. This process + will asynchronously regenerate the caches. The existing caches remains + available until it expires.` + + cmd.Annotations = make(map[string]string) + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := refreshDefaultBaseEnvironmentsJson.Unmarshal(&refreshDefaultBaseEnvironmentsReq) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } else { + return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") + } + + err = w.Libraries.RefreshDefaultBaseEnvironments(ctx, refreshDefaultBaseEnvironmentsReq) + if err != nil { + return err + } + return nil + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range refreshDefaultBaseEnvironmentsOverrides { + fn(cmd, &refreshDefaultBaseEnvironmentsReq) + } + + return cmd +} + // start uninstall command // Slice with functions to override default command behavior. @@ -288,4 +592,147 @@ func newUninstall() *cobra.Command { return cmd } +// start update-default-base-environment command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var updateDefaultBaseEnvironmentOverrides []func( + *cobra.Command, + *compute.UpdateDefaultBaseEnvironmentRequest, +) + +func newUpdateDefaultBaseEnvironment() *cobra.Command { + cmd := &cobra.Command{} + + var updateDefaultBaseEnvironmentReq compute.UpdateDefaultBaseEnvironmentRequest + var updateDefaultBaseEnvironmentJson flags.JsonFlag + + cmd.Flags().Var(&updateDefaultBaseEnvironmentJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Use = "update-default-base-environment ID" + cmd.Short = `Update a default base environment.` + cmd.Long = `Update a default base environment. + + Update the default base environment for the given ID. This process will + asynchronously regenerate the cache. The existing cache remains available + until it expires.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := updateDefaultBaseEnvironmentJson.Unmarshal(&updateDefaultBaseEnvironmentReq) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } else { + return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") + } + updateDefaultBaseEnvironmentReq.Id = args[0] + + response, err := w.Libraries.UpdateDefaultBaseEnvironment(ctx, updateDefaultBaseEnvironmentReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range updateDefaultBaseEnvironmentOverrides { + fn(cmd, &updateDefaultBaseEnvironmentReq) + } + + return cmd +} + +// start update-default-default-base-environment command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var updateDefaultDefaultBaseEnvironmentOverrides []func( + *cobra.Command, + *compute.UpdateDefaultDefaultBaseEnvironmentRequest, +) + +func newUpdateDefaultDefaultBaseEnvironment() *cobra.Command { + cmd := &cobra.Command{} + + var updateDefaultDefaultBaseEnvironmentReq compute.UpdateDefaultDefaultBaseEnvironmentRequest + var updateDefaultDefaultBaseEnvironmentJson flags.JsonFlag + + cmd.Flags().Var(&updateDefaultDefaultBaseEnvironmentJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().Var(&updateDefaultDefaultBaseEnvironmentReq.BaseEnvironmentType, "base-environment-type", `Supported values: [CPU, GPU]`) + cmd.Flags().StringVar(&updateDefaultDefaultBaseEnvironmentReq.Id, "id", updateDefaultDefaultBaseEnvironmentReq.Id, ``) + + cmd.Use = "update-default-default-base-environment" + cmd.Short = `Update the default default base environment.` + cmd.Long = `Update the default default base environment. + + Set the default base environment for the workspace. This marks the specified + DBE as the workspace default.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(0) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := updateDefaultDefaultBaseEnvironmentJson.Unmarshal(&updateDefaultDefaultBaseEnvironmentReq) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + + response, err := w.Libraries.UpdateDefaultDefaultBaseEnvironment(ctx, updateDefaultDefaultBaseEnvironmentReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range updateDefaultDefaultBaseEnvironmentOverrides { + fn(cmd, &updateDefaultDefaultBaseEnvironmentReq) + } + + return cmd +} + // end service Libraries diff --git a/cmd/workspace/model-versions/model-versions.go b/cmd/workspace/model-versions/model-versions.go index 2d47df8da6..77f2302fea 100755 --- a/cmd/workspace/model-versions/model-versions.go +++ b/cmd/workspace/model-versions/model-versions.go @@ -338,7 +338,23 @@ func newUpdate() *cobra.Command { cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) + // TODO: array: aliases + cmd.Flags().StringVar(&updateReq.CatalogName, "catalog-name", updateReq.CatalogName, `The name of the catalog containing the model version.`) cmd.Flags().StringVar(&updateReq.Comment, "comment", updateReq.Comment, `The comment attached to the model version.`) + cmd.Flags().Int64Var(&updateReq.CreatedAt, "created-at", updateReq.CreatedAt, ``) + cmd.Flags().StringVar(&updateReq.CreatedBy, "created-by", updateReq.CreatedBy, `The identifier of the user who created the model version.`) + cmd.Flags().StringVar(&updateReq.Id, "id", updateReq.Id, `The unique identifier of the model version.`) + cmd.Flags().StringVar(&updateReq.MetastoreId, "metastore-id", updateReq.MetastoreId, `The unique identifier of the metastore containing the model version.`) + cmd.Flags().StringVar(&updateReq.ModelName, "model-name", updateReq.ModelName, `The name of the parent registered model of the model version, relative to parent schema.`) + // TODO: complex arg: model_version_dependencies + cmd.Flags().StringVar(&updateReq.RunId, "run-id", updateReq.RunId, `MLflow run ID used when creating the model version, if source was generated by an experiment run stored in an MLflow tracking server.`) + cmd.Flags().IntVar(&updateReq.RunWorkspaceId, "run-workspace-id", updateReq.RunWorkspaceId, `ID of the Databricks workspace containing the MLflow run that generated this model version, if applicable.`) + cmd.Flags().StringVar(&updateReq.SchemaName, "schema-name", updateReq.SchemaName, `The name of the schema containing the model version, relative to parent catalog.`) + cmd.Flags().StringVar(&updateReq.Source, "source", updateReq.Source, `URI indicating the location of the source artifacts (files) for the model version.`) + cmd.Flags().Var(&updateReq.Status, "status", `Current status of the model version. Supported values: [FAILED_REGISTRATION, MODEL_VERSION_STATUS_UNKNOWN, PENDING_REGISTRATION, READY]`) + cmd.Flags().StringVar(&updateReq.StorageLocation, "storage-location", updateReq.StorageLocation, `The storage location on the cloud under which model version data files are stored.`) + cmd.Flags().Int64Var(&updateReq.UpdatedAt, "updated-at", updateReq.UpdatedAt, ``) + cmd.Flags().StringVar(&updateReq.UpdatedBy, "updated-by", updateReq.UpdatedBy, `The identifier of the user who updated the model version last time.`) cmd.Use = "update FULL_NAME VERSION" cmd.Short = `Update a Model Version.` diff --git a/cmd/workspace/permissions/permissions.go b/cmd/workspace/permissions/permissions.go index 1178565d7a..413d5a2712 100755 --- a/cmd/workspace/permissions/permissions.go +++ b/cmd/workspace/permissions/permissions.go @@ -95,8 +95,8 @@ func newGet() *cobra.Command { Arguments: REQUEST_OBJECT_TYPE: The type of the request object. Can be one of the following: alerts, alertsv2, authorization, clusters, cluster-policies, dashboards, - dbsql-dashboards, directories, experiments, files, instance-pools, jobs, - notebooks, pipelines, queries, registered-models, repos, + dbsql-dashboards, directories, experiments, files, genie, instance-pools, + jobs, notebooks, pipelines, queries, registered-models, repos, serving-endpoints, or warehouses. REQUEST_OBJECT_ID: The id of the request object.` @@ -157,8 +157,8 @@ func newGetPermissionLevels() *cobra.Command { Arguments: REQUEST_OBJECT_TYPE: The type of the request object. Can be one of the following: alerts, alertsv2, authorization, clusters, cluster-policies, dashboards, - dbsql-dashboards, directories, experiments, files, instance-pools, jobs, - notebooks, pipelines, queries, registered-models, repos, + dbsql-dashboards, directories, experiments, files, genie, instance-pools, + jobs, notebooks, pipelines, queries, registered-models, repos, serving-endpoints, or warehouses. REQUEST_OBJECT_ID: ` @@ -226,8 +226,8 @@ func newSet() *cobra.Command { Arguments: REQUEST_OBJECT_TYPE: The type of the request object. Can be one of the following: alerts, alertsv2, authorization, clusters, cluster-policies, dashboards, - dbsql-dashboards, directories, experiments, files, instance-pools, jobs, - notebooks, pipelines, queries, registered-models, repos, + dbsql-dashboards, directories, experiments, files, genie, instance-pools, + jobs, notebooks, pipelines, queries, registered-models, repos, serving-endpoints, or warehouses. REQUEST_OBJECT_ID: The id of the request object.` @@ -306,8 +306,8 @@ func newUpdate() *cobra.Command { Arguments: REQUEST_OBJECT_TYPE: The type of the request object. Can be one of the following: alerts, alertsv2, authorization, clusters, cluster-policies, dashboards, - dbsql-dashboards, directories, experiments, files, instance-pools, jobs, - notebooks, pipelines, queries, registered-models, repos, + dbsql-dashboards, directories, experiments, files, genie, instance-pools, + jobs, notebooks, pipelines, queries, registered-models, repos, serving-endpoints, or warehouses. REQUEST_OBJECT_ID: The id of the request object.` diff --git a/cmd/workspace/pipelines/pipelines.go b/cmd/workspace/pipelines/pipelines.go index e3e7e667c6..92c4f813e3 100755 --- a/cmd/workspace/pipelines/pipelines.go +++ b/cmd/workspace/pipelines/pipelines.go @@ -44,6 +44,7 @@ func New() *cobra.Command { } // Add methods + cmd.AddCommand(newApplyEnvironment()) cmd.AddCommand(newCreate()) cmd.AddCommand(newDelete()) cmd.AddCommand(newGet()) @@ -53,6 +54,7 @@ func New() *cobra.Command { cmd.AddCommand(newListPipelineEvents()) cmd.AddCommand(newListPipelines()) cmd.AddCommand(newListUpdates()) + cmd.AddCommand(newRestorePipeline()) cmd.AddCommand(newSetPermissions()) cmd.AddCommand(newStartUpdate()) cmd.AddCommand(newStop()) @@ -67,6 +69,72 @@ func New() *cobra.Command { return cmd } +// start apply-environment command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var applyEnvironmentOverrides []func( + *cobra.Command, + *pipelines.ApplyEnvironmentRequest, +) + +func newApplyEnvironment() *cobra.Command { + cmd := &cobra.Command{} + + var applyEnvironmentReq pipelines.ApplyEnvironmentRequest + + cmd.Use = "apply-environment PIPELINE_ID" + cmd.Short = `.` + cmd.Long = `. + + * Applies the current pipeline environment onto the pipeline compute. The + environment applied can be used by subsequent dev-mode updates.` + + cmd.Annotations = make(map[string]string) + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if len(args) == 0 { + promptSpinner := cmdio.Spinner(ctx) + promptSpinner <- "No PIPELINE_ID argument specified. Loading names for Pipelines drop-down." + names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{}) + close(promptSpinner) + if err != nil { + return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err) + } + id, err := cmdio.Select(ctx, names, "") + if err != nil { + return err + } + args = append(args, id) + } + if len(args) != 1 { + return fmt.Errorf("expected to have ") + } + applyEnvironmentReq.PipelineId = args[0] + + response, err := w.Pipelines.ApplyEnvironment(ctx, applyEnvironmentReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range applyEnvironmentOverrides { + fn(cmd, &applyEnvironmentReq) + } + + return cmd +} + // start create command // Slice with functions to override default command behavior. @@ -651,6 +719,75 @@ func newListUpdates() *cobra.Command { return cmd } +// start restore-pipeline command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var restorePipelineOverrides []func( + *cobra.Command, + *pipelines.RestorePipelineRequest, +) + +func newRestorePipeline() *cobra.Command { + cmd := &cobra.Command{} + + var restorePipelineReq pipelines.RestorePipelineRequest + + cmd.Use = "restore-pipeline PIPELINE_ID" + cmd.Short = `.` + cmd.Long = `. + + * Restores a pipeline that was previously deleted, if within the restoration + window. All tables deleted at pipeline deletion will be undropped as well. + + Arguments: + PIPELINE_ID: The ID of the pipeline to restore` + + cmd.Annotations = make(map[string]string) + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if len(args) == 0 { + promptSpinner := cmdio.Spinner(ctx) + promptSpinner <- "No PIPELINE_ID argument specified. Loading names for Pipelines drop-down." + names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{}) + close(promptSpinner) + if err != nil { + return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err) + } + id, err := cmdio.Select(ctx, names, "The ID of the pipeline to restore") + if err != nil { + return err + } + args = append(args, id) + } + if len(args) != 1 { + return fmt.Errorf("expected to have the id of the pipeline to restore") + } + restorePipelineReq.PipelineId = args[0] + + response, err := w.Pipelines.RestorePipeline(ctx, restorePipelineReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range restorePipelineOverrides { + fn(cmd, &restorePipelineReq) + } + + return cmd +} + // start set-permissions command // Slice with functions to override default command behavior. @@ -964,6 +1101,7 @@ func newUpdate() *cobra.Command { // TODO: map via StringToStringVar: tags cmd.Flags().StringVar(&updateReq.Target, "target", updateReq.Target, `Target schema (database) to add tables in this pipeline to.`) // TODO: complex arg: trigger + cmd.Flags().StringVar(&updateReq.UsagePolicyId, "usage-policy-id", updateReq.UsagePolicyId, `Usage policy of this pipeline.`) cmd.Use = "update PIPELINE_ID" cmd.Short = `Edit a pipeline.` diff --git a/cmd/workspace/query-execution/query-execution.go b/cmd/workspace/query-execution/query-execution.go new file mode 100755 index 0000000000..27f275c078 --- /dev/null +++ b/cmd/workspace/query-execution/query-execution.go @@ -0,0 +1,242 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package query_execution + +import ( + "fmt" + + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/flags" + "github.com/databricks/databricks-sdk-go/service/dashboards" + "github.com/spf13/cobra" +) + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var cmdOverrides []func(*cobra.Command) + +func New() *cobra.Command { + cmd := &cobra.Command{ + Use: "query-execution", + Short: `Query execution APIs for AI / BI Dashboards.`, + Long: `Query execution APIs for AI / BI Dashboards`, + GroupID: "dashboards", + Annotations: map[string]string{ + "package": "dashboards", + }, + + // This service is being previewed; hide from help output. + Hidden: true, + RunE: root.ReportUnknownSubcommand, + } + + // Add methods + cmd.AddCommand(newCancelPublishedQueryExecution()) + cmd.AddCommand(newExecutePublishedDashboardQuery()) + cmd.AddCommand(newPollPublishedQueryStatus()) + + // Apply optional overrides to this command. + for _, fn := range cmdOverrides { + fn(cmd) + } + + return cmd +} + +// start cancel-published-query-execution command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var cancelPublishedQueryExecutionOverrides []func( + *cobra.Command, + *dashboards.CancelPublishedQueryExecutionRequest, +) + +func newCancelPublishedQueryExecution() *cobra.Command { + cmd := &cobra.Command{} + + var cancelPublishedQueryExecutionReq dashboards.CancelPublishedQueryExecutionRequest + + // TODO: array: tokens + + cmd.Use = "cancel-published-query-execution DASHBOARD_NAME DASHBOARD_REVISION_ID" + cmd.Short = `Cancel the results for the a query for a published, embedded dashboard.` + cmd.Long = `Cancel the results for the a query for a published, embedded dashboard.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + cancelPublishedQueryExecutionReq.DashboardName = args[0] + cancelPublishedQueryExecutionReq.DashboardRevisionId = args[1] + + response, err := w.QueryExecution.CancelPublishedQueryExecution(ctx, cancelPublishedQueryExecutionReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range cancelPublishedQueryExecutionOverrides { + fn(cmd, &cancelPublishedQueryExecutionReq) + } + + return cmd +} + +// start execute-published-dashboard-query command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var executePublishedDashboardQueryOverrides []func( + *cobra.Command, + *dashboards.ExecutePublishedDashboardQueryRequest, +) + +func newExecutePublishedDashboardQuery() *cobra.Command { + cmd := &cobra.Command{} + + var executePublishedDashboardQueryReq dashboards.ExecutePublishedDashboardQueryRequest + var executePublishedDashboardQueryJson flags.JsonFlag + + cmd.Flags().Var(&executePublishedDashboardQueryJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&executePublishedDashboardQueryReq.OverrideWarehouseId, "override-warehouse-id", executePublishedDashboardQueryReq.OverrideWarehouseId, `A dashboard schedule can override the warehouse used as compute for processing the published dashboard queries.`) + + cmd.Use = "execute-published-dashboard-query DASHBOARD_NAME DASHBOARD_REVISION_ID" + cmd.Short = `Execute a query for a published dashboard.` + cmd.Long = `Execute a query for a published dashboard. + + Arguments: + DASHBOARD_NAME: Dashboard name and revision_id is required to retrieve + PublishedDatasetDataModel which contains the list of datasets, + warehouse_id, and embedded_credentials + DASHBOARD_REVISION_ID: ` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + if cmd.Flags().Changed("json") { + err := root.ExactArgs(0)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'dashboard_name', 'dashboard_revision_id' in your JSON input") + } + return nil + } + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := executePublishedDashboardQueryJson.Unmarshal(&executePublishedDashboardQueryReq) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + if !cmd.Flags().Changed("json") { + executePublishedDashboardQueryReq.DashboardName = args[0] + } + if !cmd.Flags().Changed("json") { + executePublishedDashboardQueryReq.DashboardRevisionId = args[1] + } + + err = w.QueryExecution.ExecutePublishedDashboardQuery(ctx, executePublishedDashboardQueryReq) + if err != nil { + return err + } + return nil + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range executePublishedDashboardQueryOverrides { + fn(cmd, &executePublishedDashboardQueryReq) + } + + return cmd +} + +// start poll-published-query-status command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var pollPublishedQueryStatusOverrides []func( + *cobra.Command, + *dashboards.PollPublishedQueryStatusRequest, +) + +func newPollPublishedQueryStatus() *cobra.Command { + cmd := &cobra.Command{} + + var pollPublishedQueryStatusReq dashboards.PollPublishedQueryStatusRequest + + // TODO: array: tokens + + cmd.Use = "poll-published-query-status DASHBOARD_NAME DASHBOARD_REVISION_ID" + cmd.Short = `Poll the results for the a query for a published, embedded dashboard.` + cmd.Long = `Poll the results for the a query for a published, embedded dashboard.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + pollPublishedQueryStatusReq.DashboardName = args[0] + pollPublishedQueryStatusReq.DashboardRevisionId = args[1] + + response, err := w.QueryExecution.PollPublishedQueryStatus(ctx, pollPublishedQueryStatusReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range pollPublishedQueryStatusOverrides { + fn(cmd, &pollPublishedQueryStatusReq) + } + + return cmd +} + +// end service QueryExecution diff --git a/cmd/workspace/registered-models/registered-models.go b/cmd/workspace/registered-models/registered-models.go index f98ce48fdc..06dbb39233 100755 --- a/cmd/workspace/registered-models/registered-models.go +++ b/cmd/workspace/registered-models/registered-models.go @@ -47,9 +47,9 @@ func New() *cobra.Command { update permissions on the registered model, users must be owners of the registered model. - Note: The securable type for models is "FUNCTION". When using REST APIs (e.g. - tagging, grants) that specify a securable type, use "FUNCTION" as the - securable type.`, + Note: The securable type for models is FUNCTION. When using REST APIs (e.g. + tagging, grants) that specify a securable type, use FUNCTION as the securable + type.`, GroupID: "catalog", Annotations: map[string]string{ "package": "catalog", @@ -91,10 +91,22 @@ func newCreate() *cobra.Command { cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) + // TODO: array: aliases + cmd.Flags().BoolVar(&createReq.BrowseOnly, "browse-only", createReq.BrowseOnly, `Indicates whether the principal is limited to retrieving metadata for the associated object through the BROWSE privilege when include_browse is enabled in the request.`) + cmd.Flags().StringVar(&createReq.CatalogName, "catalog-name", createReq.CatalogName, `The name of the catalog where the schema and the registered model reside.`) cmd.Flags().StringVar(&createReq.Comment, "comment", createReq.Comment, `The comment attached to the registered model.`) + cmd.Flags().Int64Var(&createReq.CreatedAt, "created-at", createReq.CreatedAt, `Creation timestamp of the registered model in milliseconds since the Unix epoch.`) + cmd.Flags().StringVar(&createReq.CreatedBy, "created-by", createReq.CreatedBy, `The identifier of the user who created the registered model.`) + cmd.Flags().StringVar(&createReq.FullName, "full-name", createReq.FullName, `The three-level (fully qualified) name of the registered model.`) + cmd.Flags().StringVar(&createReq.MetastoreId, "metastore-id", createReq.MetastoreId, `The unique identifier of the metastore.`) + cmd.Flags().StringVar(&createReq.Name, "name", createReq.Name, `The name of the registered model.`) + cmd.Flags().StringVar(&createReq.Owner, "owner", createReq.Owner, `The identifier of the user who owns the registered model.`) + cmd.Flags().StringVar(&createReq.SchemaName, "schema-name", createReq.SchemaName, `The name of the schema where the registered model resides.`) cmd.Flags().StringVar(&createReq.StorageLocation, "storage-location", createReq.StorageLocation, `The storage location on the cloud under which model version data files are stored.`) + cmd.Flags().Int64Var(&createReq.UpdatedAt, "updated-at", createReq.UpdatedAt, `Last-update timestamp of the registered model in milliseconds since the Unix epoch.`) + cmd.Flags().StringVar(&createReq.UpdatedBy, "updated-by", createReq.UpdatedBy, `The identifier of the user who updated the registered model last time.`) - cmd.Use = "create CATALOG_NAME SCHEMA_NAME NAME" + cmd.Use = "create" cmd.Short = `Create a Registered Model.` cmd.Long = `Create a Registered Model. @@ -109,24 +121,12 @@ func newCreate() *cobra.Command { parent catalog and schema, or have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema. - The caller must have the **CREATE MODEL** or **CREATE FUNCTION** privilege on the parent - schema. - - Arguments: - CATALOG_NAME: The name of the catalog where the schema and the registered model reside - SCHEMA_NAME: The name of the schema where the registered model resides - NAME: The name of the registered model` + schema.` cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { - if cmd.Flags().Changed("json") { - err := root.ExactArgs(0)(cmd, args) - if err != nil { - return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'catalog_name', 'schema_name', 'name' in your JSON input") - } - return nil - } - check := root.ExactArgs(3) + check := root.ExactArgs(0) return check(cmd, args) } @@ -147,15 +147,6 @@ func newCreate() *cobra.Command { } } } - if !cmd.Flags().Changed("json") { - createReq.CatalogName = args[0] - } - if !cmd.Flags().Changed("json") { - createReq.SchemaName = args[1] - } - if !cmd.Flags().Changed("json") { - createReq.Name = args[2] - } response, err := w.RegisteredModels.Create(ctx, createReq) if err != nil { @@ -483,7 +474,7 @@ func newSetAlias() *cobra.Command { schema. Arguments: - FULL_NAME: Full name of the registered model + FULL_NAME: The three-level (fully qualified) name of the registered model ALIAS: The name of the alias VERSION_NUM: The version number of the model version to which the alias points` @@ -563,9 +554,20 @@ func newUpdate() *cobra.Command { cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) + // TODO: array: aliases + cmd.Flags().BoolVar(&updateReq.BrowseOnly, "browse-only", updateReq.BrowseOnly, `Indicates whether the principal is limited to retrieving metadata for the associated object through the BROWSE privilege when include_browse is enabled in the request.`) + cmd.Flags().StringVar(&updateReq.CatalogName, "catalog-name", updateReq.CatalogName, `The name of the catalog where the schema and the registered model reside.`) cmd.Flags().StringVar(&updateReq.Comment, "comment", updateReq.Comment, `The comment attached to the registered model.`) + cmd.Flags().Int64Var(&updateReq.CreatedAt, "created-at", updateReq.CreatedAt, `Creation timestamp of the registered model in milliseconds since the Unix epoch.`) + cmd.Flags().StringVar(&updateReq.CreatedBy, "created-by", updateReq.CreatedBy, `The identifier of the user who created the registered model.`) + cmd.Flags().StringVar(&updateReq.MetastoreId, "metastore-id", updateReq.MetastoreId, `The unique identifier of the metastore.`) + cmd.Flags().StringVar(&updateReq.Name, "name", updateReq.Name, `The name of the registered model.`) cmd.Flags().StringVar(&updateReq.NewName, "new-name", updateReq.NewName, `New name for the registered model.`) cmd.Flags().StringVar(&updateReq.Owner, "owner", updateReq.Owner, `The identifier of the user who owns the registered model.`) + cmd.Flags().StringVar(&updateReq.SchemaName, "schema-name", updateReq.SchemaName, `The name of the schema where the registered model resides.`) + cmd.Flags().StringVar(&updateReq.StorageLocation, "storage-location", updateReq.StorageLocation, `The storage location on the cloud under which model version data files are stored.`) + cmd.Flags().Int64Var(&updateReq.UpdatedAt, "updated-at", updateReq.UpdatedAt, `Last-update timestamp of the registered model in milliseconds since the Unix epoch.`) + cmd.Flags().StringVar(&updateReq.UpdatedBy, "updated-by", updateReq.UpdatedBy, `The identifier of the user who updated the registered model last time.`) cmd.Use = "update FULL_NAME" cmd.Short = `Update a Registered Model.` diff --git a/cmd/workspace/serving-endpoints/serving-endpoints.go b/cmd/workspace/serving-endpoints/serving-endpoints.go index 287f9d4575..3a7ceefd7d 100755 --- a/cmd/workspace/serving-endpoints/serving-endpoints.go +++ b/cmd/workspace/serving-endpoints/serving-endpoints.go @@ -61,6 +61,7 @@ func New() *cobra.Command { cmd.AddCommand(newQuery()) cmd.AddCommand(newSetPermissions()) cmd.AddCommand(newUpdateConfig()) + cmd.AddCommand(newUpdateNotifications()) cmd.AddCommand(newUpdatePermissions()) cmd.AddCommand(newUpdateProvisionedThroughputEndpointConfig()) @@ -1324,6 +1325,80 @@ func newUpdateConfig() *cobra.Command { return cmd } +// start update-notifications command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var updateNotificationsOverrides []func( + *cobra.Command, + *serving.UpdateInferenceEndpointNotifications, +) + +func newUpdateNotifications() *cobra.Command { + cmd := &cobra.Command{} + + var updateNotificationsReq serving.UpdateInferenceEndpointNotifications + var updateNotificationsJson flags.JsonFlag + + cmd.Flags().Var(&updateNotificationsJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + // TODO: complex arg: email_notifications + + cmd.Use = "update-notifications NAME" + cmd.Short = `Update the email and webhook notification settings for an endpoint.` + cmd.Long = `Update the email and webhook notification settings for an endpoint. + + Updates the email and webhook notification settings for an endpoint. + + Arguments: + NAME: The name of the serving endpoint whose notifications are being updated. + This field is required.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := updateNotificationsJson.Unmarshal(&updateNotificationsReq) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + updateNotificationsReq.Name = args[0] + + response, err := w.ServingEndpoints.UpdateNotifications(ctx, updateNotificationsReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range updateNotificationsOverrides { + fn(cmd, &updateNotificationsReq) + } + + return cmd +} + // start update-permissions command // Slice with functions to override default command behavior. diff --git a/cmd/workspace/shares/shares.go b/cmd/workspace/shares/shares.go index 803b1f05cc..bc3bcdb35f 100755 --- a/cmd/workspace/shares/shares.go +++ b/cmd/workspace/shares/shares.go @@ -68,6 +68,7 @@ func newCreate() *cobra.Command { cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) cmd.Flags().StringVar(&createReq.Comment, "comment", createReq.Comment, `User-provided free-form text description.`) + cmd.Flags().StringVar(&createReq.ServerlessBudgetPolicyId, "serverless-budget-policy-id", createReq.ServerlessBudgetPolicyId, `Serverless budget policy id (can only be created/updated when calling data-sharing service) [Create,Update:IGN].`) cmd.Flags().StringVar(&createReq.StorageRoot, "storage-root", createReq.StorageRoot, `Storage root URL for the share.`) cmd.Use = "create NAME" @@ -384,6 +385,7 @@ func newUpdate() *cobra.Command { cmd.Flags().StringVar(&updateReq.Comment, "comment", updateReq.Comment, `User-provided free-form text description.`) cmd.Flags().StringVar(&updateReq.NewName, "new-name", updateReq.NewName, `New name for the share.`) cmd.Flags().StringVar(&updateReq.Owner, "owner", updateReq.Owner, `Username of current owner of share.`) + cmd.Flags().StringVar(&updateReq.ServerlessBudgetPolicyId, "serverless-budget-policy-id", updateReq.ServerlessBudgetPolicyId, `Serverless budget policy id (can only be created/updated when calling data-sharing service) [Create,Update:IGN].`) cmd.Flags().StringVar(&updateReq.StorageRoot, "storage-root", updateReq.StorageRoot, `Storage root URL for the share.`) // TODO: array: updates diff --git a/cmd/workspace/storage-credentials/storage-credentials.go b/cmd/workspace/storage-credentials/storage-credentials.go index 483a0155e6..2d24a4f1c1 100755 --- a/cmd/workspace/storage-credentials/storage-credentials.go +++ b/cmd/workspace/storage-credentials/storage-credentials.go @@ -281,6 +281,7 @@ func newList() *cobra.Command { var listReq catalog.ListStorageCredentialsRequest + cmd.Flags().BoolVar(&listReq.IncludeUnbound, "include-unbound", listReq.IncludeUnbound, `Whether to include credentials not bound to the workspace.`) cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Maximum number of storage credentials to return.`) cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Opaque pagination token to go to next page based on previous query.`) diff --git a/cmd/workspace/tag-assignments/tag-assignments.go b/cmd/workspace/tag-assignments/tag-assignments.go new file mode 100755 index 0000000000..52d6bb7af7 --- /dev/null +++ b/cmd/workspace/tag-assignments/tag-assignments.go @@ -0,0 +1,418 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package tag_assignments + +import ( + "fmt" + + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/flags" + "github.com/databricks/databricks-sdk-go/service/tags" + "github.com/spf13/cobra" +) + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var cmdOverrides []func(*cobra.Command) + +func New() *cobra.Command { + cmd := &cobra.Command{ + Use: "tag-assignments", + Short: `Manage tag assignments on workspace-scoped objects.`, + Long: `Manage tag assignments on workspace-scoped objects.`, + GroupID: "tags", + Annotations: map[string]string{ + "package": "tags", + }, + + // This service is being previewed; hide from help output. + Hidden: true, + RunE: root.ReportUnknownSubcommand, + } + + // Add methods + cmd.AddCommand(newCreateTagAssignment()) + cmd.AddCommand(newDeleteTagAssignment()) + cmd.AddCommand(newGetTagAssignment()) + cmd.AddCommand(newListTagAssignments()) + cmd.AddCommand(newUpdateTagAssignment()) + + // Apply optional overrides to this command. + for _, fn := range cmdOverrides { + fn(cmd) + } + + return cmd +} + +// start create-tag-assignment command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var createTagAssignmentOverrides []func( + *cobra.Command, + *tags.CreateTagAssignmentRequest, +) + +func newCreateTagAssignment() *cobra.Command { + cmd := &cobra.Command{} + + var createTagAssignmentReq tags.CreateTagAssignmentRequest + createTagAssignmentReq.TagAssignment = tags.TagAssignment{} + var createTagAssignmentJson flags.JsonFlag + + cmd.Flags().Var(&createTagAssignmentJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&createTagAssignmentReq.TagAssignment.TagValue, "tag-value", createTagAssignmentReq.TagAssignment.TagValue, `The value of the tag.`) + + cmd.Use = "create-tag-assignment ENTITY_TYPE ENTITY_ID TAG_KEY" + cmd.Short = `Create a tag assignment for an entity.` + cmd.Long = `Create a tag assignment for an entity. + + Create a tag assignment + + Arguments: + ENTITY_TYPE: The type of entity to which the tag is assigned. Allowed value is + dashboards + ENTITY_ID: The identifier of the entity to which the tag is assigned + TAG_KEY: The key of the tag. The characters , . : / - = and leading/trailing spaces + are not allowed` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + if cmd.Flags().Changed("json") { + err := root.ExactArgs(0)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'entity_type', 'entity_id', 'tag_key' in your JSON input") + } + return nil + } + check := root.ExactArgs(3) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := createTagAssignmentJson.Unmarshal(&createTagAssignmentReq.TagAssignment) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + if !cmd.Flags().Changed("json") { + createTagAssignmentReq.TagAssignment.EntityType = args[0] + } + if !cmd.Flags().Changed("json") { + createTagAssignmentReq.TagAssignment.EntityId = args[1] + } + if !cmd.Flags().Changed("json") { + createTagAssignmentReq.TagAssignment.TagKey = args[2] + } + + response, err := w.TagAssignments.CreateTagAssignment(ctx, createTagAssignmentReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range createTagAssignmentOverrides { + fn(cmd, &createTagAssignmentReq) + } + + return cmd +} + +// start delete-tag-assignment command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var deleteTagAssignmentOverrides []func( + *cobra.Command, + *tags.DeleteTagAssignmentRequest, +) + +func newDeleteTagAssignment() *cobra.Command { + cmd := &cobra.Command{} + + var deleteTagAssignmentReq tags.DeleteTagAssignmentRequest + + cmd.Use = "delete-tag-assignment ENTITY_TYPE ENTITY_ID TAG_KEY" + cmd.Short = `Delete a tag assignment for an entity.` + cmd.Long = `Delete a tag assignment for an entity. + + Delete a tag assignment + + Arguments: + ENTITY_TYPE: The type of entity to which the tag is assigned. Allowed value is + dashboards + ENTITY_ID: The identifier of the entity to which the tag is assigned + TAG_KEY: The key of the tag. The characters , . : / - = and leading/trailing spaces + are not allowed` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(3) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + deleteTagAssignmentReq.EntityType = args[0] + deleteTagAssignmentReq.EntityId = args[1] + deleteTagAssignmentReq.TagKey = args[2] + + err = w.TagAssignments.DeleteTagAssignment(ctx, deleteTagAssignmentReq) + if err != nil { + return err + } + return nil + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range deleteTagAssignmentOverrides { + fn(cmd, &deleteTagAssignmentReq) + } + + return cmd +} + +// start get-tag-assignment command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var getTagAssignmentOverrides []func( + *cobra.Command, + *tags.GetTagAssignmentRequest, +) + +func newGetTagAssignment() *cobra.Command { + cmd := &cobra.Command{} + + var getTagAssignmentReq tags.GetTagAssignmentRequest + + cmd.Use = "get-tag-assignment ENTITY_TYPE ENTITY_ID TAG_KEY" + cmd.Short = `Get a tag assignment for an entity.` + cmd.Long = `Get a tag assignment for an entity. + + Get a tag assignment + + Arguments: + ENTITY_TYPE: The type of entity to which the tag is assigned. Allowed value is + dashboards + ENTITY_ID: The identifier of the entity to which the tag is assigned + TAG_KEY: The key of the tag. The characters , . : / - = and leading/trailing spaces + are not allowed` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(3) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + getTagAssignmentReq.EntityType = args[0] + getTagAssignmentReq.EntityId = args[1] + getTagAssignmentReq.TagKey = args[2] + + response, err := w.TagAssignments.GetTagAssignment(ctx, getTagAssignmentReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range getTagAssignmentOverrides { + fn(cmd, &getTagAssignmentReq) + } + + return cmd +} + +// start list-tag-assignments command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var listTagAssignmentsOverrides []func( + *cobra.Command, + *tags.ListTagAssignmentsRequest, +) + +func newListTagAssignments() *cobra.Command { + cmd := &cobra.Command{} + + var listTagAssignmentsReq tags.ListTagAssignmentsRequest + + cmd.Flags().IntVar(&listTagAssignmentsReq.PageSize, "page-size", listTagAssignmentsReq.PageSize, `Optional.`) + cmd.Flags().StringVar(&listTagAssignmentsReq.PageToken, "page-token", listTagAssignmentsReq.PageToken, `Pagination token to go to the next page of tag assignments.`) + + cmd.Use = "list-tag-assignments ENTITY_TYPE ENTITY_ID" + cmd.Short = `List tag assignments for an entity.` + cmd.Long = `List tag assignments for an entity. + + List the tag assignments for an entity + + Arguments: + ENTITY_TYPE: The type of entity to which the tag is assigned. Allowed value is + dashboards + ENTITY_ID: The identifier of the entity to which the tag is assigned` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + listTagAssignmentsReq.EntityType = args[0] + listTagAssignmentsReq.EntityId = args[1] + + response := w.TagAssignments.ListTagAssignments(ctx, listTagAssignmentsReq) + return cmdio.RenderIterator(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range listTagAssignmentsOverrides { + fn(cmd, &listTagAssignmentsReq) + } + + return cmd +} + +// start update-tag-assignment command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var updateTagAssignmentOverrides []func( + *cobra.Command, + *tags.UpdateTagAssignmentRequest, +) + +func newUpdateTagAssignment() *cobra.Command { + cmd := &cobra.Command{} + + var updateTagAssignmentReq tags.UpdateTagAssignmentRequest + updateTagAssignmentReq.TagAssignment = tags.TagAssignment{} + var updateTagAssignmentJson flags.JsonFlag + + cmd.Flags().Var(&updateTagAssignmentJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&updateTagAssignmentReq.TagAssignment.TagValue, "tag-value", updateTagAssignmentReq.TagAssignment.TagValue, `The value of the tag.`) + + cmd.Use = "update-tag-assignment ENTITY_TYPE ENTITY_ID TAG_KEY UPDATE_MASK" + cmd.Short = `Update a tag assignment for an entity.` + cmd.Long = `Update a tag assignment for an entity. + + Update a tag assignment + + Arguments: + ENTITY_TYPE: The type of entity to which the tag is assigned. Allowed value is + dashboards + ENTITY_ID: The identifier of the entity to which the tag is assigned + TAG_KEY: The key of the tag. The characters , . : / - = and leading/trailing spaces + are not allowed + UPDATE_MASK: The field mask must be a single string, with multiple fields separated by + commas (no spaces). The field path is relative to the resource object, + using a dot (.) to navigate sub-fields (e.g., author.given_name). + Specification of elements in sequence or map fields is not allowed, as + only the entire collection field can be specified. Field names must + exactly match the resource field names. + + A field mask of * indicates full replacement. It’s recommended to + always explicitly list the fields being updated and avoid using * + wildcards, as it can lead to unintended results if the API changes in the + future.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(4) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := updateTagAssignmentJson.Unmarshal(&updateTagAssignmentReq.TagAssignment) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + updateTagAssignmentReq.EntityType = args[0] + updateTagAssignmentReq.EntityId = args[1] + updateTagAssignmentReq.TagKey = args[2] + updateTagAssignmentReq.UpdateMask = args[3] + + response, err := w.TagAssignments.UpdateTagAssignment(ctx, updateTagAssignmentReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range updateTagAssignmentOverrides { + fn(cmd, &updateTagAssignmentReq) + } + + return cmd +} + +// end service TagAssignments diff --git a/cmd/workspace/vector-search-endpoints/vector-search-endpoints.go b/cmd/workspace/vector-search-endpoints/vector-search-endpoints.go index 17da8b0a74..5e5cd9048b 100755 --- a/cmd/workspace/vector-search-endpoints/vector-search-endpoints.go +++ b/cmd/workspace/vector-search-endpoints/vector-search-endpoints.go @@ -70,6 +70,7 @@ func newCreateEndpoint() *cobra.Command { cmd.Flags().Var(&createEndpointJson, "json", `either inline JSON string or @path/to/file.json with request body`) cmd.Flags().StringVar(&createEndpointReq.BudgetPolicyId, "budget-policy-id", createEndpointReq.BudgetPolicyId, `The budget policy id to be applied.`) + cmd.Flags().StringVar(&createEndpointReq.UsagePolicyId, "usage-policy-id", createEndpointReq.UsagePolicyId, `The usage policy id to be applied once we've migrated to usage policies.`) cmd.Use = "create-endpoint NAME ENDPOINT_TYPE" cmd.Short = `Create an endpoint.` diff --git a/cmd/workspace/vector-search-indexes/vector-search-indexes.go b/cmd/workspace/vector-search-indexes/vector-search-indexes.go index b39fa35b40..345ef982da 100755 --- a/cmd/workspace/vector-search-indexes/vector-search-indexes.go +++ b/cmd/workspace/vector-search-indexes/vector-search-indexes.go @@ -47,6 +47,7 @@ func New() *cobra.Command { cmd.AddCommand(newQueryNextPage()) cmd.AddCommand(newScanIndex()) cmd.AddCommand(newSyncIndex()) + cmd.AddCommand(newUpdateIndexBudgetPolicy()) cmd.AddCommand(newUpsertDataVectorIndex()) // Apply optional overrides to this command. @@ -683,6 +684,62 @@ func newSyncIndex() *cobra.Command { return cmd } +// start update-index-budget-policy command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var updateIndexBudgetPolicyOverrides []func( + *cobra.Command, + *vectorsearch.UpdateVectorIndexUsagePolicyRequest, +) + +func newUpdateIndexBudgetPolicy() *cobra.Command { + cmd := &cobra.Command{} + + var updateIndexBudgetPolicyReq vectorsearch.UpdateVectorIndexUsagePolicyRequest + + cmd.Use = "update-index-budget-policy INDEX_NAME" + cmd.Short = `Update the usage policy of an index.` + cmd.Long = `Update the usage policy of an index. + + Update the budget policy of an index + + Arguments: + INDEX_NAME: Name of the vector search index` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + updateIndexBudgetPolicyReq.IndexName = args[0] + + response, err := w.VectorSearchIndexes.UpdateIndexBudgetPolicy(ctx, updateIndexBudgetPolicyReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range updateIndexBudgetPolicyOverrides { + fn(cmd, &updateIndexBudgetPolicyReq) + } + + return cmd +} + // start upsert-data-vector-index command // Slice with functions to override default command behavior. diff --git a/cmd/workspace/volumes/volumes.go b/cmd/workspace/volumes/volumes.go index ce76a94fc5..006e30d400 100755 --- a/cmd/workspace/volumes/volumes.go +++ b/cmd/workspace/volumes/volumes.go @@ -98,7 +98,12 @@ func newCreate() *cobra.Command { CATALOG_NAME: The name of the catalog where the schema and the volume are SCHEMA_NAME: The name of the schema where the volume is NAME: The name of the volume - VOLUME_TYPE: + VOLUME_TYPE: The type of the volume. An external volume is located in the specified + external location. A managed volume is located in the default location + which is specified by the parent schema, or the parent catalog, or the + Metastore. [Learn more] + + [Learn more]: https://docs.databricks.com/aws/en/volumes/managed-vs-external Supported values: [EXTERNAL, MANAGED]` cmd.Annotations = make(map[string]string) @@ -267,7 +272,7 @@ func newList() *cobra.Command { The returned volumes are filtered based on the privileges of the calling user. For example, the metastore admin is able to list all the volumes. A regular user needs to be the owner or have the **READ VOLUME** privilege on the volume - to recieve the volumes in the response. For the latter case, the caller must + to receive the volumes in the response. For the latter case, the caller must also be the owner or have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema. diff --git a/cmd/workspace/warehouses/warehouses.go b/cmd/workspace/warehouses/warehouses.go index 439d988074..966b886444 100755 --- a/cmd/workspace/warehouses/warehouses.go +++ b/cmd/workspace/warehouses/warehouses.go @@ -88,9 +88,9 @@ func newCreate() *cobra.Command { cmd.Flags().IntVar(&createReq.MaxNumClusters, "max-num-clusters", createReq.MaxNumClusters, `Maximum number of clusters that the autoscaler will create to handle concurrent queries.`) cmd.Flags().IntVar(&createReq.MinNumClusters, "min-num-clusters", createReq.MinNumClusters, `Minimum number of available clusters that will be maintained for this SQL warehouse.`) cmd.Flags().StringVar(&createReq.Name, "name", createReq.Name, `Logical name for the cluster.`) - cmd.Flags().Var(&createReq.SpotInstancePolicy, "spot-instance-policy", `Supported values: [COST_OPTIMIZED, POLICY_UNSPECIFIED, RELIABILITY_OPTIMIZED]`) + cmd.Flags().Var(&createReq.SpotInstancePolicy, "spot-instance-policy", `Configurations whether the endpoint should use spot instances. Supported values: [COST_OPTIMIZED, POLICY_UNSPECIFIED, RELIABILITY_OPTIMIZED]`) // TODO: complex arg: tags - cmd.Flags().Var(&createReq.WarehouseType, "warehouse-type", `Supported values: [CLASSIC, PRO, TYPE_UNSPECIFIED]`) + cmd.Flags().Var(&createReq.WarehouseType, "warehouse-type", `Warehouse type: PRO or CLASSIC. Supported values: [CLASSIC, PRO, TYPE_UNSPECIFIED]`) cmd.Use = "create" cmd.Short = `Create a warehouse.` @@ -262,9 +262,9 @@ func newEdit() *cobra.Command { cmd.Flags().IntVar(&editReq.MaxNumClusters, "max-num-clusters", editReq.MaxNumClusters, `Maximum number of clusters that the autoscaler will create to handle concurrent queries.`) cmd.Flags().IntVar(&editReq.MinNumClusters, "min-num-clusters", editReq.MinNumClusters, `Minimum number of available clusters that will be maintained for this SQL warehouse.`) cmd.Flags().StringVar(&editReq.Name, "name", editReq.Name, `Logical name for the cluster.`) - cmd.Flags().Var(&editReq.SpotInstancePolicy, "spot-instance-policy", `Supported values: [COST_OPTIMIZED, POLICY_UNSPECIFIED, RELIABILITY_OPTIMIZED]`) + cmd.Flags().Var(&editReq.SpotInstancePolicy, "spot-instance-policy", `Configurations whether the endpoint should use spot instances. Supported values: [COST_OPTIMIZED, POLICY_UNSPECIFIED, RELIABILITY_OPTIMIZED]`) // TODO: complex arg: tags - cmd.Flags().Var(&editReq.WarehouseType, "warehouse-type", `Supported values: [CLASSIC, PRO, TYPE_UNSPECIFIED]`) + cmd.Flags().Var(&editReq.WarehouseType, "warehouse-type", `Warehouse type: PRO or CLASSIC. Supported values: [CLASSIC, PRO, TYPE_UNSPECIFIED]`) cmd.Use = "edit ID" cmd.Short = `Update a warehouse.` @@ -613,7 +613,9 @@ func newList() *cobra.Command { var listReq sql.ListWarehousesRequest - cmd.Flags().IntVar(&listReq.RunAsUserId, "run-as-user-id", listReq.RunAsUserId, `Service Principal which will be used to fetch the list of warehouses.`) + cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, `The max number of warehouses to return.`) + cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `A page token, received from a previous ListWarehouses call.`) + cmd.Flags().IntVar(&listReq.RunAsUserId, "run-as-user-id", listReq.RunAsUserId, `Service Principal which will be used to fetch the list of endpoints.`) cmd.Use = "list" cmd.Short = `List warehouses.` @@ -756,10 +758,11 @@ func newSetWorkspaceWarehouseConfig() *cobra.Command { // TODO: complex arg: channel // TODO: complex arg: config_param // TODO: array: data_access_config + cmd.Flags().BoolVar(&setWorkspaceWarehouseConfigReq.EnableServerlessCompute, "enable-serverless-compute", setWorkspaceWarehouseConfigReq.EnableServerlessCompute, `Enable Serverless compute for SQL warehouses.`) // TODO: array: enabled_warehouse_types // TODO: complex arg: global_param cmd.Flags().StringVar(&setWorkspaceWarehouseConfigReq.GoogleServiceAccount, "google-service-account", setWorkspaceWarehouseConfigReq.GoogleServiceAccount, `GCP only: Google Service Account used to pass to cluster to access Google Cloud Storage.`) - cmd.Flags().StringVar(&setWorkspaceWarehouseConfigReq.InstanceProfileArn, "instance-profile-arn", setWorkspaceWarehouseConfigReq.InstanceProfileArn, `AWS Only: Instance profile used to pass IAM role to the cluster.`) + cmd.Flags().StringVar(&setWorkspaceWarehouseConfigReq.InstanceProfileArn, "instance-profile-arn", setWorkspaceWarehouseConfigReq.InstanceProfileArn, `AWS Only: The instance profile used to pass an IAM role to the SQL warehouses.`) cmd.Flags().Var(&setWorkspaceWarehouseConfigReq.SecurityPolicy, "security-policy", `Security policy for warehouses. Supported values: [DATA_ACCESS_CONTROL, NONE, PASSTHROUGH]`) // TODO: complex arg: sql_configuration_parameters diff --git a/cmd/workspace/workspace-iam-v2/workspace-iam-v2.go b/cmd/workspace/workspace-iam-v2/workspace-iam-v2.go index bfa75ba936..60d71eed06 100755 --- a/cmd/workspace/workspace-iam-v2/workspace-iam-v2.go +++ b/cmd/workspace/workspace-iam-v2/workspace-iam-v2.go @@ -31,10 +31,29 @@ func New() *cobra.Command { } // Add methods + cmd.AddCommand(newCreateGroupProxy()) + cmd.AddCommand(newCreateServicePrincipalProxy()) + cmd.AddCommand(newCreateUserProxy()) + cmd.AddCommand(newCreateWorkspaceAccessDetailLocal()) + cmd.AddCommand(newDeleteGroupProxy()) + cmd.AddCommand(newDeleteServicePrincipalProxy()) + cmd.AddCommand(newDeleteUserProxy()) + cmd.AddCommand(newDeleteWorkspaceAccessDetailLocal()) + cmd.AddCommand(newGetGroupProxy()) + cmd.AddCommand(newGetServicePrincipalProxy()) + cmd.AddCommand(newGetUserProxy()) cmd.AddCommand(newGetWorkspaceAccessDetailLocal()) + cmd.AddCommand(newListGroupsProxy()) + cmd.AddCommand(newListServicePrincipalsProxy()) + cmd.AddCommand(newListUsersProxy()) + cmd.AddCommand(newListWorkspaceAccessDetailsLocal()) cmd.AddCommand(newResolveGroupProxy()) cmd.AddCommand(newResolveServicePrincipalProxy()) cmd.AddCommand(newResolveUserProxy()) + cmd.AddCommand(newUpdateGroupProxy()) + cmd.AddCommand(newUpdateServicePrincipalProxy()) + cmd.AddCommand(newUpdateUserProxy()) + cmd.AddCommand(newUpdateWorkspaceAccessDetailLocal()) // Apply optional overrides to this command. for _, fn := range cmdOverrides { @@ -44,6 +63,719 @@ func New() *cobra.Command { return cmd } +// start create-group-proxy command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var createGroupProxyOverrides []func( + *cobra.Command, + *iamv2.CreateGroupProxyRequest, +) + +func newCreateGroupProxy() *cobra.Command { + cmd := &cobra.Command{} + + var createGroupProxyReq iamv2.CreateGroupProxyRequest + createGroupProxyReq.Group = iamv2.Group{} + var createGroupProxyJson flags.JsonFlag + + cmd.Flags().Var(&createGroupProxyJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&createGroupProxyReq.Group.ExternalId, "external-id", createGroupProxyReq.Group.ExternalId, `ExternalId of the group in the customer's IdP.`) + cmd.Flags().StringVar(&createGroupProxyReq.Group.GroupName, "group-name", createGroupProxyReq.Group.GroupName, `Display name of the group.`) + + cmd.Use = "create-group-proxy" + cmd.Short = `Create a group in the account.` + cmd.Long = `Create a group in the account. + + TODO: Write description later when this method is implemented` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(0) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := createGroupProxyJson.Unmarshal(&createGroupProxyReq.Group) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + + response, err := w.WorkspaceIamV2.CreateGroupProxy(ctx, createGroupProxyReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range createGroupProxyOverrides { + fn(cmd, &createGroupProxyReq) + } + + return cmd +} + +// start create-service-principal-proxy command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var createServicePrincipalProxyOverrides []func( + *cobra.Command, + *iamv2.CreateServicePrincipalProxyRequest, +) + +func newCreateServicePrincipalProxy() *cobra.Command { + cmd := &cobra.Command{} + + var createServicePrincipalProxyReq iamv2.CreateServicePrincipalProxyRequest + createServicePrincipalProxyReq.ServicePrincipal = iamv2.ServicePrincipal{} + var createServicePrincipalProxyJson flags.JsonFlag + + cmd.Flags().Var(&createServicePrincipalProxyJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().Var(&createServicePrincipalProxyReq.ServicePrincipal.AccountSpStatus, "account-sp-status", `The activity status of a service principal in a Databricks account. Supported values: [ACTIVE, INACTIVE]`) + cmd.Flags().StringVar(&createServicePrincipalProxyReq.ServicePrincipal.ApplicationId, "application-id", createServicePrincipalProxyReq.ServicePrincipal.ApplicationId, `Application ID of the service principal.`) + cmd.Flags().StringVar(&createServicePrincipalProxyReq.ServicePrincipal.DisplayName, "display-name", createServicePrincipalProxyReq.ServicePrincipal.DisplayName, `Display name of the service principal.`) + cmd.Flags().StringVar(&createServicePrincipalProxyReq.ServicePrincipal.ExternalId, "external-id", createServicePrincipalProxyReq.ServicePrincipal.ExternalId, `ExternalId of the service principal in the customer's IdP.`) + + cmd.Use = "create-service-principal-proxy" + cmd.Short = `Create a service principal in the account.` + cmd.Long = `Create a service principal in the account. + + TODO: Write description later when this method is implemented` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(0) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := createServicePrincipalProxyJson.Unmarshal(&createServicePrincipalProxyReq.ServicePrincipal) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + + response, err := w.WorkspaceIamV2.CreateServicePrincipalProxy(ctx, createServicePrincipalProxyReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range createServicePrincipalProxyOverrides { + fn(cmd, &createServicePrincipalProxyReq) + } + + return cmd +} + +// start create-user-proxy command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var createUserProxyOverrides []func( + *cobra.Command, + *iamv2.CreateUserProxyRequest, +) + +func newCreateUserProxy() *cobra.Command { + cmd := &cobra.Command{} + + var createUserProxyReq iamv2.CreateUserProxyRequest + createUserProxyReq.User = iamv2.User{} + var createUserProxyJson flags.JsonFlag + + cmd.Flags().Var(&createUserProxyJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().Var(&createUserProxyReq.User.AccountUserStatus, "account-user-status", `The activity status of a user in a Databricks account. Supported values: [ACTIVE, INACTIVE]`) + cmd.Flags().StringVar(&createUserProxyReq.User.ExternalId, "external-id", createUserProxyReq.User.ExternalId, `ExternalId of the user in the customer's IdP.`) + // TODO: complex arg: name + + cmd.Use = "create-user-proxy USERNAME" + cmd.Short = `Create a user in the account.` + cmd.Long = `Create a user in the account. + + TODO: Write description later when this method is implemented + + Arguments: + USERNAME: Username/email of the user.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + if cmd.Flags().Changed("json") { + err := root.ExactArgs(0)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'username' in your JSON input") + } + return nil + } + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := createUserProxyJson.Unmarshal(&createUserProxyReq.User) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + if !cmd.Flags().Changed("json") { + createUserProxyReq.User.Username = args[0] + } + + response, err := w.WorkspaceIamV2.CreateUserProxy(ctx, createUserProxyReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range createUserProxyOverrides { + fn(cmd, &createUserProxyReq) + } + + return cmd +} + +// start create-workspace-access-detail-local command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var createWorkspaceAccessDetailLocalOverrides []func( + *cobra.Command, + *iamv2.CreateWorkspaceAccessDetailLocalRequest, +) + +func newCreateWorkspaceAccessDetailLocal() *cobra.Command { + cmd := &cobra.Command{} + + var createWorkspaceAccessDetailLocalReq iamv2.CreateWorkspaceAccessDetailLocalRequest + createWorkspaceAccessDetailLocalReq.WorkspaceAccessDetail = iamv2.WorkspaceAccessDetail{} + var createWorkspaceAccessDetailLocalJson flags.JsonFlag + + cmd.Flags().Var(&createWorkspaceAccessDetailLocalJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + // TODO: array: permissions + cmd.Flags().Var(&createWorkspaceAccessDetailLocalReq.WorkspaceAccessDetail.Status, "status", `The activity status of the principal in the workspace. Supported values: [ACTIVE, INACTIVE]`) + + cmd.Use = "create-workspace-access-detail-local" + cmd.Short = `Define workspace access for a principal.` + cmd.Long = `Define workspace access for a principal. + + TODO: Write description later when this method is implemented` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(0) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := createWorkspaceAccessDetailLocalJson.Unmarshal(&createWorkspaceAccessDetailLocalReq.WorkspaceAccessDetail) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + + response, err := w.WorkspaceIamV2.CreateWorkspaceAccessDetailLocal(ctx, createWorkspaceAccessDetailLocalReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range createWorkspaceAccessDetailLocalOverrides { + fn(cmd, &createWorkspaceAccessDetailLocalReq) + } + + return cmd +} + +// start delete-group-proxy command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var deleteGroupProxyOverrides []func( + *cobra.Command, + *iamv2.DeleteGroupProxyRequest, +) + +func newDeleteGroupProxy() *cobra.Command { + cmd := &cobra.Command{} + + var deleteGroupProxyReq iamv2.DeleteGroupProxyRequest + + cmd.Use = "delete-group-proxy INTERNAL_ID" + cmd.Short = `Delete a group in the account.` + cmd.Long = `Delete a group in the account. + + TODO: Write description later when this method is implemented + + Arguments: + INTERNAL_ID: Required. Internal ID of the group in Databricks.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + _, err = fmt.Sscan(args[0], &deleteGroupProxyReq.InternalId) + if err != nil { + return fmt.Errorf("invalid INTERNAL_ID: %s", args[0]) + } + + err = w.WorkspaceIamV2.DeleteGroupProxy(ctx, deleteGroupProxyReq) + if err != nil { + return err + } + return nil + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range deleteGroupProxyOverrides { + fn(cmd, &deleteGroupProxyReq) + } + + return cmd +} + +// start delete-service-principal-proxy command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var deleteServicePrincipalProxyOverrides []func( + *cobra.Command, + *iamv2.DeleteServicePrincipalProxyRequest, +) + +func newDeleteServicePrincipalProxy() *cobra.Command { + cmd := &cobra.Command{} + + var deleteServicePrincipalProxyReq iamv2.DeleteServicePrincipalProxyRequest + + cmd.Use = "delete-service-principal-proxy INTERNAL_ID" + cmd.Short = `Delete a service principal in the account.` + cmd.Long = `Delete a service principal in the account. + + TODO: Write description later when this method is implemented + + Arguments: + INTERNAL_ID: Required. Internal ID of the service principal in Databricks.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + _, err = fmt.Sscan(args[0], &deleteServicePrincipalProxyReq.InternalId) + if err != nil { + return fmt.Errorf("invalid INTERNAL_ID: %s", args[0]) + } + + err = w.WorkspaceIamV2.DeleteServicePrincipalProxy(ctx, deleteServicePrincipalProxyReq) + if err != nil { + return err + } + return nil + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range deleteServicePrincipalProxyOverrides { + fn(cmd, &deleteServicePrincipalProxyReq) + } + + return cmd +} + +// start delete-user-proxy command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var deleteUserProxyOverrides []func( + *cobra.Command, + *iamv2.DeleteUserProxyRequest, +) + +func newDeleteUserProxy() *cobra.Command { + cmd := &cobra.Command{} + + var deleteUserProxyReq iamv2.DeleteUserProxyRequest + + cmd.Use = "delete-user-proxy INTERNAL_ID" + cmd.Short = `Delete a user in the account.` + cmd.Long = `Delete a user in the account. + + TODO: Write description later when this method is implemented + + Arguments: + INTERNAL_ID: Required. Internal ID of the user in Databricks.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + _, err = fmt.Sscan(args[0], &deleteUserProxyReq.InternalId) + if err != nil { + return fmt.Errorf("invalid INTERNAL_ID: %s", args[0]) + } + + err = w.WorkspaceIamV2.DeleteUserProxy(ctx, deleteUserProxyReq) + if err != nil { + return err + } + return nil + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range deleteUserProxyOverrides { + fn(cmd, &deleteUserProxyReq) + } + + return cmd +} + +// start delete-workspace-access-detail-local command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var deleteWorkspaceAccessDetailLocalOverrides []func( + *cobra.Command, + *iamv2.DeleteWorkspaceAccessDetailLocalRequest, +) + +func newDeleteWorkspaceAccessDetailLocal() *cobra.Command { + cmd := &cobra.Command{} + + var deleteWorkspaceAccessDetailLocalReq iamv2.DeleteWorkspaceAccessDetailLocalRequest + + cmd.Use = "delete-workspace-access-detail-local PRINCIPAL_ID" + cmd.Short = `Delete workspace access for a principal.` + cmd.Long = `Delete workspace access for a principal. + + TODO: Write description later when this method is implemented + + Arguments: + PRINCIPAL_ID: Required. ID of the principal in Databricks.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + _, err = fmt.Sscan(args[0], &deleteWorkspaceAccessDetailLocalReq.PrincipalId) + if err != nil { + return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[0]) + } + + err = w.WorkspaceIamV2.DeleteWorkspaceAccessDetailLocal(ctx, deleteWorkspaceAccessDetailLocalReq) + if err != nil { + return err + } + return nil + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range deleteWorkspaceAccessDetailLocalOverrides { + fn(cmd, &deleteWorkspaceAccessDetailLocalReq) + } + + return cmd +} + +// start get-group-proxy command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var getGroupProxyOverrides []func( + *cobra.Command, + *iamv2.GetGroupProxyRequest, +) + +func newGetGroupProxy() *cobra.Command { + cmd := &cobra.Command{} + + var getGroupProxyReq iamv2.GetGroupProxyRequest + + cmd.Use = "get-group-proxy INTERNAL_ID" + cmd.Short = `Get a group in the account.` + cmd.Long = `Get a group in the account. + + TODO: Write description later when this method is implemented + + Arguments: + INTERNAL_ID: Required. Internal ID of the group in Databricks.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + _, err = fmt.Sscan(args[0], &getGroupProxyReq.InternalId) + if err != nil { + return fmt.Errorf("invalid INTERNAL_ID: %s", args[0]) + } + + response, err := w.WorkspaceIamV2.GetGroupProxy(ctx, getGroupProxyReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range getGroupProxyOverrides { + fn(cmd, &getGroupProxyReq) + } + + return cmd +} + +// start get-service-principal-proxy command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var getServicePrincipalProxyOverrides []func( + *cobra.Command, + *iamv2.GetServicePrincipalProxyRequest, +) + +func newGetServicePrincipalProxy() *cobra.Command { + cmd := &cobra.Command{} + + var getServicePrincipalProxyReq iamv2.GetServicePrincipalProxyRequest + + cmd.Use = "get-service-principal-proxy INTERNAL_ID" + cmd.Short = `Get a service principal in the account.` + cmd.Long = `Get a service principal in the account. + + TODO: Write description later when this method is implemented + + Arguments: + INTERNAL_ID: Required. Internal ID of the service principal in Databricks.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + _, err = fmt.Sscan(args[0], &getServicePrincipalProxyReq.InternalId) + if err != nil { + return fmt.Errorf("invalid INTERNAL_ID: %s", args[0]) + } + + response, err := w.WorkspaceIamV2.GetServicePrincipalProxy(ctx, getServicePrincipalProxyReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range getServicePrincipalProxyOverrides { + fn(cmd, &getServicePrincipalProxyReq) + } + + return cmd +} + +// start get-user-proxy command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var getUserProxyOverrides []func( + *cobra.Command, + *iamv2.GetUserProxyRequest, +) + +func newGetUserProxy() *cobra.Command { + cmd := &cobra.Command{} + + var getUserProxyReq iamv2.GetUserProxyRequest + + cmd.Use = "get-user-proxy INTERNAL_ID" + cmd.Short = `Get a user in the account.` + cmd.Long = `Get a user in the account. + + TODO: Write description later when this method is implemented + + Arguments: + INTERNAL_ID: Required. Internal ID of the user in Databricks.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + _, err = fmt.Sscan(args[0], &getUserProxyReq.InternalId) + if err != nil { + return fmt.Errorf("invalid INTERNAL_ID: %s", args[0]) + } + + response, err := w.WorkspaceIamV2.GetUserProxy(ctx, getUserProxyReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range getUserProxyOverrides { + fn(cmd, &getUserProxyReq) + } + + return cmd +} + // start get-workspace-access-detail-local command // Slice with functions to override default command behavior. @@ -56,29 +788,250 @@ var getWorkspaceAccessDetailLocalOverrides []func( func newGetWorkspaceAccessDetailLocal() *cobra.Command { cmd := &cobra.Command{} - var getWorkspaceAccessDetailLocalReq iamv2.GetWorkspaceAccessDetailLocalRequest + var getWorkspaceAccessDetailLocalReq iamv2.GetWorkspaceAccessDetailLocalRequest + + cmd.Flags().Var(&getWorkspaceAccessDetailLocalReq.View, "view", `Controls what fields are returned. Supported values: [BASIC, FULL]`) + + cmd.Use = "get-workspace-access-detail-local PRINCIPAL_ID" + cmd.Short = `Get workspace access details for a principal.` + cmd.Long = `Get workspace access details for a principal. + + Returns the access details for a principal in the current workspace. Allows + for checking access details for any provisioned principal (user, service + principal, or group) in the current workspace. * Provisioned principal here + refers to one that has been synced into Databricks from the customer's IdP or + added explicitly to Databricks via SCIM/UI. Allows for passing in a "view" + parameter to control what fields are returned (BASIC by default or FULL). + + Arguments: + PRINCIPAL_ID: Required. The internal ID of the principal (user/sp/group) for which the + access details are being requested.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + _, err = fmt.Sscan(args[0], &getWorkspaceAccessDetailLocalReq.PrincipalId) + if err != nil { + return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[0]) + } + + response, err := w.WorkspaceIamV2.GetWorkspaceAccessDetailLocal(ctx, getWorkspaceAccessDetailLocalReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range getWorkspaceAccessDetailLocalOverrides { + fn(cmd, &getWorkspaceAccessDetailLocalReq) + } + + return cmd +} + +// start list-groups-proxy command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var listGroupsProxyOverrides []func( + *cobra.Command, + *iamv2.ListGroupsProxyRequest, +) + +func newListGroupsProxy() *cobra.Command { + cmd := &cobra.Command{} + + var listGroupsProxyReq iamv2.ListGroupsProxyRequest + + cmd.Flags().IntVar(&listGroupsProxyReq.PageSize, "page-size", listGroupsProxyReq.PageSize, `The maximum number of groups to return.`) + cmd.Flags().StringVar(&listGroupsProxyReq.PageToken, "page-token", listGroupsProxyReq.PageToken, `A page token, received from a previous ListGroups call.`) + + cmd.Use = "list-groups-proxy" + cmd.Short = `List groups in the account.` + cmd.Long = `List groups in the account. + + TODO: Write description later when this method is implemented` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(0) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + response, err := w.WorkspaceIamV2.ListGroupsProxy(ctx, listGroupsProxyReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range listGroupsProxyOverrides { + fn(cmd, &listGroupsProxyReq) + } + + return cmd +} + +// start list-service-principals-proxy command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var listServicePrincipalsProxyOverrides []func( + *cobra.Command, + *iamv2.ListServicePrincipalsProxyRequest, +) + +func newListServicePrincipalsProxy() *cobra.Command { + cmd := &cobra.Command{} + + var listServicePrincipalsProxyReq iamv2.ListServicePrincipalsProxyRequest + + cmd.Flags().IntVar(&listServicePrincipalsProxyReq.PageSize, "page-size", listServicePrincipalsProxyReq.PageSize, `The maximum number of SPs to return.`) + cmd.Flags().StringVar(&listServicePrincipalsProxyReq.PageToken, "page-token", listServicePrincipalsProxyReq.PageToken, `A page token, received from a previous ListServicePrincipals call.`) + + cmd.Use = "list-service-principals-proxy" + cmd.Short = `List service principals in the account.` + cmd.Long = `List service principals in the account. + + TODO: Write description later when this method is implemented` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(0) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + response, err := w.WorkspaceIamV2.ListServicePrincipalsProxy(ctx, listServicePrincipalsProxyReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range listServicePrincipalsProxyOverrides { + fn(cmd, &listServicePrincipalsProxyReq) + } + + return cmd +} + +// start list-users-proxy command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var listUsersProxyOverrides []func( + *cobra.Command, + *iamv2.ListUsersProxyRequest, +) + +func newListUsersProxy() *cobra.Command { + cmd := &cobra.Command{} + + var listUsersProxyReq iamv2.ListUsersProxyRequest + + cmd.Flags().IntVar(&listUsersProxyReq.PageSize, "page-size", listUsersProxyReq.PageSize, `The maximum number of users to return.`) + cmd.Flags().StringVar(&listUsersProxyReq.PageToken, "page-token", listUsersProxyReq.PageToken, `A page token, received from a previous ListUsers call.`) + + cmd.Use = "list-users-proxy" + cmd.Short = `List users in the account.` + cmd.Long = `List users in the account. + + TODO: Write description later when this method is implemented` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(0) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + response, err := w.WorkspaceIamV2.ListUsersProxy(ctx, listUsersProxyReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range listUsersProxyOverrides { + fn(cmd, &listUsersProxyReq) + } + + return cmd +} + +// start list-workspace-access-details-local command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var listWorkspaceAccessDetailsLocalOverrides []func( + *cobra.Command, + *iamv2.ListWorkspaceAccessDetailsLocalRequest, +) + +func newListWorkspaceAccessDetailsLocal() *cobra.Command { + cmd := &cobra.Command{} + + var listWorkspaceAccessDetailsLocalReq iamv2.ListWorkspaceAccessDetailsLocalRequest - cmd.Flags().Var(&getWorkspaceAccessDetailLocalReq.View, "view", `Controls what fields are returned. Supported values: [BASIC, FULL]`) + cmd.Flags().IntVar(&listWorkspaceAccessDetailsLocalReq.PageSize, "page-size", listWorkspaceAccessDetailsLocalReq.PageSize, `The maximum number of workspace access details to return.`) + cmd.Flags().StringVar(&listWorkspaceAccessDetailsLocalReq.PageToken, "page-token", listWorkspaceAccessDetailsLocalReq.PageToken, `A page token, received from a previous ListWorkspaceAccessDetails call.`) - cmd.Use = "get-workspace-access-detail-local PRINCIPAL_ID" - cmd.Short = `Get workspace access details for a principal.` - cmd.Long = `Get workspace access details for a principal. + cmd.Use = "list-workspace-access-details-local" + cmd.Short = `List workspace access details for a workspace.` + cmd.Long = `List workspace access details for a workspace. - Returns the access details for a principal in the current workspace. Allows - for checking access details for any provisioned principal (user, service - principal, or group) in the current workspace. * Provisioned principal here - refers to one that has been synced into Databricks from the customer's IdP or - added explicitly to Databricks via SCIM/UI. Allows for passing in a "view" - parameter to control what fields are returned (BASIC by default or FULL). - - Arguments: - PRINCIPAL_ID: Required. The internal ID of the principal (user/sp/group) for which the - access details are being requested.` + TODO: Write description later when this method is implemented` cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { - check := root.ExactArgs(1) + check := root.ExactArgs(0) return check(cmd, args) } @@ -87,12 +1040,7 @@ func newGetWorkspaceAccessDetailLocal() *cobra.Command { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - _, err = fmt.Sscan(args[0], &getWorkspaceAccessDetailLocalReq.PrincipalId) - if err != nil { - return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[0]) - } - - response, err := w.WorkspaceIamV2.GetWorkspaceAccessDetailLocal(ctx, getWorkspaceAccessDetailLocalReq) + response, err := w.WorkspaceIamV2.ListWorkspaceAccessDetailsLocal(ctx, listWorkspaceAccessDetailsLocalReq) if err != nil { return err } @@ -104,8 +1052,8 @@ func newGetWorkspaceAccessDetailLocal() *cobra.Command { cmd.ValidArgsFunction = cobra.NoFileCompletions // Apply optional overrides to this command. - for _, fn := range getWorkspaceAccessDetailLocalOverrides { - fn(cmd, &getWorkspaceAccessDetailLocalReq) + for _, fn := range listWorkspaceAccessDetailsLocalOverrides { + fn(cmd, &listWorkspaceAccessDetailsLocalReq) } return cmd @@ -358,4 +1306,338 @@ func newResolveUserProxy() *cobra.Command { return cmd } +// start update-group-proxy command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var updateGroupProxyOverrides []func( + *cobra.Command, + *iamv2.UpdateGroupProxyRequest, +) + +func newUpdateGroupProxy() *cobra.Command { + cmd := &cobra.Command{} + + var updateGroupProxyReq iamv2.UpdateGroupProxyRequest + updateGroupProxyReq.Group = iamv2.Group{} + var updateGroupProxyJson flags.JsonFlag + + cmd.Flags().Var(&updateGroupProxyJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&updateGroupProxyReq.Group.ExternalId, "external-id", updateGroupProxyReq.Group.ExternalId, `ExternalId of the group in the customer's IdP.`) + cmd.Flags().StringVar(&updateGroupProxyReq.Group.GroupName, "group-name", updateGroupProxyReq.Group.GroupName, `Display name of the group.`) + + cmd.Use = "update-group-proxy INTERNAL_ID UPDATE_MASK" + cmd.Short = `Update a group in the account.` + cmd.Long = `Update a group in the account. + + TODO: Write description later when this method is implemented + + Arguments: + INTERNAL_ID: Required. Internal ID of the group in Databricks. + UPDATE_MASK: Optional. The list of fields to update.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := updateGroupProxyJson.Unmarshal(&updateGroupProxyReq.Group) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + _, err = fmt.Sscan(args[0], &updateGroupProxyReq.InternalId) + if err != nil { + return fmt.Errorf("invalid INTERNAL_ID: %s", args[0]) + } + updateGroupProxyReq.UpdateMask = args[1] + + response, err := w.WorkspaceIamV2.UpdateGroupProxy(ctx, updateGroupProxyReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range updateGroupProxyOverrides { + fn(cmd, &updateGroupProxyReq) + } + + return cmd +} + +// start update-service-principal-proxy command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var updateServicePrincipalProxyOverrides []func( + *cobra.Command, + *iamv2.UpdateServicePrincipalProxyRequest, +) + +func newUpdateServicePrincipalProxy() *cobra.Command { + cmd := &cobra.Command{} + + var updateServicePrincipalProxyReq iamv2.UpdateServicePrincipalProxyRequest + updateServicePrincipalProxyReq.ServicePrincipal = iamv2.ServicePrincipal{} + var updateServicePrincipalProxyJson flags.JsonFlag + + cmd.Flags().Var(&updateServicePrincipalProxyJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().Var(&updateServicePrincipalProxyReq.ServicePrincipal.AccountSpStatus, "account-sp-status", `The activity status of a service principal in a Databricks account. Supported values: [ACTIVE, INACTIVE]`) + cmd.Flags().StringVar(&updateServicePrincipalProxyReq.ServicePrincipal.ApplicationId, "application-id", updateServicePrincipalProxyReq.ServicePrincipal.ApplicationId, `Application ID of the service principal.`) + cmd.Flags().StringVar(&updateServicePrincipalProxyReq.ServicePrincipal.DisplayName, "display-name", updateServicePrincipalProxyReq.ServicePrincipal.DisplayName, `Display name of the service principal.`) + cmd.Flags().StringVar(&updateServicePrincipalProxyReq.ServicePrincipal.ExternalId, "external-id", updateServicePrincipalProxyReq.ServicePrincipal.ExternalId, `ExternalId of the service principal in the customer's IdP.`) + + cmd.Use = "update-service-principal-proxy INTERNAL_ID UPDATE_MASK" + cmd.Short = `Update a service principal in the account.` + cmd.Long = `Update a service principal in the account. + + TODO: Write description later when this method is implemented + + Arguments: + INTERNAL_ID: Required. Internal ID of the service principal in Databricks. + UPDATE_MASK: Optional. The list of fields to update.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := updateServicePrincipalProxyJson.Unmarshal(&updateServicePrincipalProxyReq.ServicePrincipal) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + _, err = fmt.Sscan(args[0], &updateServicePrincipalProxyReq.InternalId) + if err != nil { + return fmt.Errorf("invalid INTERNAL_ID: %s", args[0]) + } + updateServicePrincipalProxyReq.UpdateMask = args[1] + + response, err := w.WorkspaceIamV2.UpdateServicePrincipalProxy(ctx, updateServicePrincipalProxyReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range updateServicePrincipalProxyOverrides { + fn(cmd, &updateServicePrincipalProxyReq) + } + + return cmd +} + +// start update-user-proxy command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var updateUserProxyOverrides []func( + *cobra.Command, + *iamv2.UpdateUserProxyRequest, +) + +func newUpdateUserProxy() *cobra.Command { + cmd := &cobra.Command{} + + var updateUserProxyReq iamv2.UpdateUserProxyRequest + updateUserProxyReq.User = iamv2.User{} + var updateUserProxyJson flags.JsonFlag + + cmd.Flags().Var(&updateUserProxyJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().Var(&updateUserProxyReq.User.AccountUserStatus, "account-user-status", `The activity status of a user in a Databricks account. Supported values: [ACTIVE, INACTIVE]`) + cmd.Flags().StringVar(&updateUserProxyReq.User.ExternalId, "external-id", updateUserProxyReq.User.ExternalId, `ExternalId of the user in the customer's IdP.`) + // TODO: complex arg: name + + cmd.Use = "update-user-proxy INTERNAL_ID UPDATE_MASK USERNAME" + cmd.Short = `Update a user in the account.` + cmd.Long = `Update a user in the account. + + TODO: Write description later when this method is implemented + + Arguments: + INTERNAL_ID: Required. Internal ID of the user in Databricks. + UPDATE_MASK: Optional. The list of fields to update. + USERNAME: Username/email of the user.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + if cmd.Flags().Changed("json") { + err := root.ExactArgs(2)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, provide only INTERNAL_ID, UPDATE_MASK as positional arguments. Provide 'username' in your JSON input") + } + return nil + } + check := root.ExactArgs(3) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := updateUserProxyJson.Unmarshal(&updateUserProxyReq.User) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + _, err = fmt.Sscan(args[0], &updateUserProxyReq.InternalId) + if err != nil { + return fmt.Errorf("invalid INTERNAL_ID: %s", args[0]) + } + updateUserProxyReq.UpdateMask = args[1] + if !cmd.Flags().Changed("json") { + updateUserProxyReq.User.Username = args[2] + } + + response, err := w.WorkspaceIamV2.UpdateUserProxy(ctx, updateUserProxyReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range updateUserProxyOverrides { + fn(cmd, &updateUserProxyReq) + } + + return cmd +} + +// start update-workspace-access-detail-local command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var updateWorkspaceAccessDetailLocalOverrides []func( + *cobra.Command, + *iamv2.UpdateWorkspaceAccessDetailLocalRequest, +) + +func newUpdateWorkspaceAccessDetailLocal() *cobra.Command { + cmd := &cobra.Command{} + + var updateWorkspaceAccessDetailLocalReq iamv2.UpdateWorkspaceAccessDetailLocalRequest + updateWorkspaceAccessDetailLocalReq.WorkspaceAccessDetail = iamv2.WorkspaceAccessDetail{} + var updateWorkspaceAccessDetailLocalJson flags.JsonFlag + + cmd.Flags().Var(&updateWorkspaceAccessDetailLocalJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + // TODO: array: permissions + cmd.Flags().Var(&updateWorkspaceAccessDetailLocalReq.WorkspaceAccessDetail.Status, "status", `The activity status of the principal in the workspace. Supported values: [ACTIVE, INACTIVE]`) + + cmd.Use = "update-workspace-access-detail-local PRINCIPAL_ID UPDATE_MASK" + cmd.Short = `Update workspace access for a principal.` + cmd.Long = `Update workspace access for a principal. + + TODO: Write description later when this method is implemented + + Arguments: + PRINCIPAL_ID: Required. ID of the principal in Databricks. + UPDATE_MASK: Optional. The list of fields to update.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := updateWorkspaceAccessDetailLocalJson.Unmarshal(&updateWorkspaceAccessDetailLocalReq.WorkspaceAccessDetail) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + _, err = fmt.Sscan(args[0], &updateWorkspaceAccessDetailLocalReq.PrincipalId) + if err != nil { + return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[0]) + } + updateWorkspaceAccessDetailLocalReq.UpdateMask = args[1] + + response, err := w.WorkspaceIamV2.UpdateWorkspaceAccessDetailLocal(ctx, updateWorkspaceAccessDetailLocalReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range updateWorkspaceAccessDetailLocalOverrides { + fn(cmd, &updateWorkspaceAccessDetailLocalReq) + } + + return cmd +} + // end service workspace_iamV2 diff --git a/cmd/workspace/workspace/workspace.go b/cmd/workspace/workspace/workspace.go index c7339ab0e8..d2e3f1c9c6 100755 --- a/cmd/workspace/workspace/workspace.go +++ b/cmd/workspace/workspace/workspace.go @@ -180,6 +180,7 @@ func newExport() *cobra.Command { R_MARKDOWN, SOURCE, ]`) + cmd.Flags().Var(&exportReq.Outputs, "outputs", `This specifies which cell outputs should be included in the export (if the export format allows it). Supported values: [ALL, NONE]`) cmd.Use = "export PATH" cmd.Short = `Export a workspace object.` diff --git a/go.mod b/go.mod index 65928cef4c..fa43c6a22f 100644 --- a/go.mod +++ b/go.mod @@ -90,3 +90,5 @@ tool ( github.com/google/yamlfmt/cmd/yamlfmt gotest.tools/gotestsum ) + +replace github.com/databricks/databricks-sdk-go => ../databricks-sdk-go \ No newline at end of file From acd2a9b9d7bd0f723a3416a18daa8735f99fc899 Mon Sep 17 00:00:00 2001 From: Parth Bansal Date: Thu, 9 Oct 2025 17:02:57 +0000 Subject: [PATCH 2/9] update --- cmd/account/budgets/budgets.go | 2 +- cmd/account/cmd.go | 4 +- cmd/account/iam-v2/iam-v2.go | 59 +++++++- cmd/account/workspaces/workspaces.go | 9 ++ cmd/workspace/catalogs/catalogs.go | 11 +- cmd/workspace/cmd.go | 4 +- cmd/workspace/connections/connections.go | 11 +- cmd/workspace/data-quality/data-quality.go | 4 +- cmd/workspace/database/database.go | 6 + cmd/workspace/experiments/experiments.go | 3 + .../external-locations/external-locations.go | 11 +- cmd/workspace/forecasting/forecasting.go | 2 +- cmd/workspace/functions/functions.go | 9 ++ cmd/workspace/genie/genie.go | 12 ++ .../git-credentials/git-credentials.go | 6 +- .../lakeview-embedded/lakeview-embedded.go | 3 + cmd/workspace/libraries/libraries.go | 23 ++- cmd/workspace/metastores/metastores.go | 11 +- cmd/workspace/pipelines/pipelines.go | 6 + .../quality-monitor-v2/quality-monitor-v2.go | 141 ++++++++++++++++++ .../query-visualizations-legacy.go | 10 +- cmd/workspace/schemas/schemas.go | 9 ++ cmd/workspace/shares/shares.go | 2 +- .../storage-credentials.go | 11 +- .../system-schemas/system-schemas.go | 9 ++ cmd/workspace/tables/tables.go | 9 ++ .../vector-search-indexes.go | 3 + .../workspace-iam-v2/workspace-iam-v2.go | 59 +++++++- 28 files changed, 424 insertions(+), 25 deletions(-) diff --git a/cmd/account/budgets/budgets.go b/cmd/account/budgets/budgets.go index c2911784a3..71c4621801 100755 --- a/cmd/account/budgets/budgets.go +++ b/cmd/account/budgets/budgets.go @@ -350,4 +350,4 @@ func newUpdate() *cobra.Command { return cmd } -// end service budgets +// end service Budgets diff --git a/cmd/account/cmd.go b/cmd/account/cmd.go index de152f3719..cc6d3bc5e1 100644 --- a/cmd/account/cmd.go +++ b/cmd/account/cmd.go @@ -54,11 +54,13 @@ func New() *cobra.Command { cmd.AddCommand(account_access_control.New()) cmd.AddCommand(billable_usage.New()) cmd.AddCommand(budget_policy.New()) + cmd.AddCommand(budgets.New()) cmd.AddCommand(credentials.New()) cmd.AddCommand(custom_app_integration.New()) cmd.AddCommand(encryption_keys.New()) cmd.AddCommand(account_federation_policy.New()) cmd.AddCommand(account_groups_v2.New()) + cmd.AddCommand(account_iam_v2.New()) cmd.AddCommand(account_ip_access_lists.New()) cmd.AddCommand(log_delivery.New()) cmd.AddCommand(account_metastore_assignments.New()) @@ -83,8 +85,6 @@ func New() *cobra.Command { cmd.AddCommand(workspace_assignment.New()) cmd.AddCommand(workspace_network_configuration.New()) cmd.AddCommand(workspaces.New()) - cmd.AddCommand(account_iam_v2.New()) - cmd.AddCommand(budgets.New()) cmd.AddCommand(account_groups.New()) cmd.AddCommand(account_service_principals.New()) diff --git a/cmd/account/iam-v2/iam-v2.go b/cmd/account/iam-v2/iam-v2.go index 71c5d74a9d..8da13ee6bd 100755 --- a/cmd/account/iam-v2/iam-v2.go +++ b/cmd/account/iam-v2/iam-v2.go @@ -90,6 +90,9 @@ func newCreateGroup() *cobra.Command { TODO: Write description later when this method is implemented` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -163,6 +166,9 @@ func newCreateServicePrincipal() *cobra.Command { TODO: Write description later when this method is implemented` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -238,6 +244,9 @@ func newCreateUser() *cobra.Command { Arguments: USERNAME: Username/email of the user.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -322,6 +331,9 @@ func newCreateWorkspaceAccessDetail() *cobra.Command { Arguments: PARENT: Required. The parent path for workspace access detail.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -390,6 +402,9 @@ func newDeleteGroup() *cobra.Command { Arguments: INTERNAL_ID: Required. Internal ID of the group in Databricks.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -449,6 +464,9 @@ func newDeleteServicePrincipal() *cobra.Command { Arguments: INTERNAL_ID: Required. Internal ID of the service principal in Databricks.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -508,6 +526,9 @@ func newDeleteUser() *cobra.Command { Arguments: INTERNAL_ID: Required. Internal ID of the user in Databricks.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -569,6 +590,9 @@ func newDeleteWorkspaceAccessDetail() *cobra.Command { PRINCIPAL_ID: Required. ID of the principal in Databricks to delete workspace access for.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -632,6 +656,9 @@ func newGetGroup() *cobra.Command { Arguments: INTERNAL_ID: Required. Internal ID of the group in Databricks.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -691,6 +718,9 @@ func newGetServicePrincipal() *cobra.Command { Arguments: INTERNAL_ID: Required. Internal ID of the service principal in Databricks.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -750,6 +780,9 @@ func newGetUser() *cobra.Command { Arguments: INTERNAL_ID: Required. Internal ID of the user in Databricks.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -882,6 +915,9 @@ func newListGroups() *cobra.Command { TODO: Write description later when this method is implemented` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -936,6 +972,9 @@ func newListServicePrincipals() *cobra.Command { TODO: Write description later when this method is implemented` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -990,6 +1029,9 @@ func newListUsers() *cobra.Command { TODO: Write description later when this method is implemented` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -1047,6 +1089,9 @@ func newListWorkspaceAccessDetails() *cobra.Command { Arguments: WORKSPACE_ID: The workspace ID for which the workspace access details are being fetched.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -1361,6 +1406,9 @@ func newUpdateGroup() *cobra.Command { INTERNAL_ID: Required. Internal ID of the group in Databricks. UPDATE_MASK: Optional. The list of fields to update.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -1443,6 +1491,9 @@ func newUpdateServicePrincipal() *cobra.Command { INTERNAL_ID: Required. Internal ID of the service principal in Databricks. UPDATE_MASK: Optional. The list of fields to update.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -1525,6 +1576,9 @@ func newUpdateUser() *cobra.Command { UPDATE_MASK: Optional. The list of fields to update. USERNAME: Username/email of the user.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -1617,6 +1671,9 @@ func newUpdateWorkspaceAccessDetail() *cobra.Command { PRINCIPAL_ID: Required. ID of the principal in Databricks. UPDATE_MASK: Optional. The list of fields to update.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -1670,4 +1727,4 @@ func newUpdateWorkspaceAccessDetail() *cobra.Command { return cmd } -// end service account_iamV2 +// end service AccountIamV2 diff --git a/cmd/account/workspaces/workspaces.go b/cmd/account/workspaces/workspaces.go index 7c922b10ca..5fc50b7385 100755 --- a/cmd/account/workspaces/workspaces.go +++ b/cmd/account/workspaces/workspaces.go @@ -78,6 +78,7 @@ func newCreate() *cobra.Command { cmd.Flags().StringVar(&createReq.AwsRegion, "aws-region", createReq.AwsRegion, ``) cmd.Flags().StringVar(&createReq.Cloud, "cloud", createReq.Cloud, `The cloud name.`) // TODO: complex arg: cloud_resource_container + cmd.Flags().Var(&createReq.ComputeMode, "compute-mode", `If the compute mode is SERVERLESS, a serverless workspace is created that comes pre-configured with serverless compute and default storage, providing a fully-managed, enterprise-ready SaaS experience. Supported values: [HYBRID, SERVERLESS]`) cmd.Flags().StringVar(&createReq.CredentialsId, "credentials-id", createReq.CredentialsId, `ID of the workspace's credential configuration object.`) // TODO: map via StringToStringVar: custom_tags cmd.Flags().StringVar(&createReq.DeploymentName, "deployment-name", createReq.DeploymentName, `The deployment name defines part of the subdomain for the workspace.`) @@ -390,6 +391,14 @@ func newUpdate() *cobra.Command { cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.CredentialsId, "credentials-id", updateReq.CustomerFacingWorkspace.CredentialsId, `ID of the workspace's credential configuration object.`) // TODO: map via StringToStringVar: custom_tags cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.DeploymentName, "deployment-name", updateReq.CustomerFacingWorkspace.DeploymentName, ``) + cmd.Flags().Var(&updateReq.CustomerFacingWorkspace.ExpectedWorkspaceStatus, "expected-workspace-status", `A client owned field used to indicate the workspace status that the client expects to be in. Supported values: [ + BANNED, + CANCELLING, + FAILED, + NOT_PROVISIONED, + PROVISIONING, + RUNNING, +]`) // TODO: complex arg: gcp_managed_network_config // TODO: complex arg: gke_config cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.Location, "location", updateReq.CustomerFacingWorkspace.Location, `The Google Cloud region of the workspace data plane in your Google account (for example, us-east4).`) diff --git a/cmd/workspace/catalogs/catalogs.go b/cmd/workspace/catalogs/catalogs.go index 77347cbd39..e9940dfa6d 100755 --- a/cmd/workspace/catalogs/catalogs.go +++ b/cmd/workspace/catalogs/catalogs.go @@ -288,7 +288,16 @@ func newList() *cobra.Command { admin, all catalogs will be retrieved. Otherwise, only catalogs owned by the caller (or for which the caller has the **USE_CATALOG** privilege) will be retrieved. There is no guarantee of a specific ordering of the elements in the - array.` + array. + + NOTE: we recommend using max_results=0 to use the paginated version of this + API. Unpaginated calls will be deprecated soon. + + PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may + contain zero results while still providing a next_page_token. Clients must + continue reading pages until next_page_token is absent, which is the only + indication that the end of results has been reached. This behavior follows + Google AIP-158 guidelines.` cmd.Annotations = make(map[string]string) diff --git a/cmd/workspace/cmd.go b/cmd/workspace/cmd.go index a8a86941a0..f0f88de9c3 100755 --- a/cmd/workspace/cmd.go +++ b/cmd/workspace/cmd.go @@ -167,6 +167,7 @@ func All() []*cobra.Command { out = append(out, external_metadata.New()) out = append(out, feature_engineering.New()) out = append(out, feature_store.New()) + out = append(out, forecasting.New()) out = append(out, functions.New()) out = append(out, genie.New()) out = append(out, git_credentials.New()) @@ -242,9 +243,8 @@ func All() []*cobra.Command { out = append(out, workspace.New()) out = append(out, workspace_bindings.New()) out = append(out, workspace_conf.New()) - out = append(out, workspace_settings_v2.New()) - out = append(out, forecasting.New()) out = append(out, workspace_iam_v2.New()) + out = append(out, workspace_settings_v2.New()) out = append(out, groups.New()) out = append(out, service_principals.New()) diff --git a/cmd/workspace/connections/connections.go b/cmd/workspace/connections/connections.go index 761f278c29..da74aa3c43 100755 --- a/cmd/workspace/connections/connections.go +++ b/cmd/workspace/connections/connections.go @@ -284,7 +284,16 @@ func newList() *cobra.Command { cmd.Short = `List connections.` cmd.Long = `List connections. - List all connections.` + List all connections. + + NOTE: we recommend using max_results=0 to use the paginated version of this + API. Unpaginated calls will be deprecated soon. + + PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may + contain zero results while still providing a next_page_token. Clients must + continue reading pages until next_page_token is absent, which is the only + indication that the end of results has been reached. This behavior follows + Google AIP-158 guidelines.` cmd.Annotations = make(map[string]string) diff --git a/cmd/workspace/data-quality/data-quality.go b/cmd/workspace/data-quality/data-quality.go index d02ff35a2b..f7423666fc 100755 --- a/cmd/workspace/data-quality/data-quality.go +++ b/cmd/workspace/data-quality/data-quality.go @@ -726,7 +726,9 @@ func newUpdateMonitor() *cobra.Command { OBJECT_TYPE: The type of the monitored object. Can be one of the following: schema or table. OBJECT_ID: The UUID of the request object. For example, schema id. - UPDATE_MASK: The field mask to specify which fields to update. + UPDATE_MASK: The field mask to specify which fields to update as a comma-separated + list. Example value: + data_profiling_config.custom_metrics,data_profiling_config.schedule.quartz_cron_expression OBJECT_TYPE: The type of the monitored object. Can be one of the following: schema or table. OBJECT_ID: The UUID of the request object. For example, schema id.` diff --git a/cmd/workspace/database/database.go b/cmd/workspace/database/database.go index 90671fc135..873bd7b981 100755 --- a/cmd/workspace/database/database.go +++ b/cmd/workspace/database/database.go @@ -827,6 +827,9 @@ func newFailoverDatabaseInstance() *cobra.Command { Arguments: NAME: Name of the instance to failover.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -1699,6 +1702,9 @@ func newUpdateDatabaseInstanceRole() *cobra.Command { NAME: The name of the role. This is the unique identifier for the role in an instance.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { diff --git a/cmd/workspace/experiments/experiments.go b/cmd/workspace/experiments/experiments.go index c648a60a6d..558461966a 100755 --- a/cmd/workspace/experiments/experiments.go +++ b/cmd/workspace/experiments/experiments.go @@ -1125,6 +1125,9 @@ func newGetLoggedModels() *cobra.Command { Batch endpoint for getting logged models from a list of model IDs` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { diff --git a/cmd/workspace/external-locations/external-locations.go b/cmd/workspace/external-locations/external-locations.go index 0d10c3b243..14dffa1769 100755 --- a/cmd/workspace/external-locations/external-locations.go +++ b/cmd/workspace/external-locations/external-locations.go @@ -299,7 +299,16 @@ func newList() *cobra.Command { Gets an array of external locations (__ExternalLocationInfo__ objects) from the metastore. The caller must be a metastore admin, the owner of the external location, or a user that has some privilege on the external location. There is - no guarantee of a specific ordering of the elements in the array.` + no guarantee of a specific ordering of the elements in the array. + + NOTE: we recommend using max_results=0 to use the paginated version of this + API. Unpaginated calls will be deprecated soon. + + PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may + contain zero results while still providing a next_page_token. Clients must + continue reading pages until next_page_token is absent, which is the only + indication that the end of results has been reached. This behavior follows + Google AIP-158 guidelines.` cmd.Annotations = make(map[string]string) diff --git a/cmd/workspace/forecasting/forecasting.go b/cmd/workspace/forecasting/forecasting.go index 383c135a0d..676fe21bb2 100755 --- a/cmd/workspace/forecasting/forecasting.go +++ b/cmd/workspace/forecasting/forecasting.go @@ -243,4 +243,4 @@ func newGetExperiment() *cobra.Command { return cmd } -// end service forecasting +// end service Forecasting diff --git a/cmd/workspace/functions/functions.go b/cmd/workspace/functions/functions.go index 850631ac6f..bd104fedb2 100755 --- a/cmd/workspace/functions/functions.go +++ b/cmd/workspace/functions/functions.go @@ -301,6 +301,15 @@ func newList() *cobra.Command { functions for which either the user has the **EXECUTE** privilege or the user is the owner. There is no guarantee of a specific ordering of the elements in the array. + + NOTE: we recommend using max_results=0 to use the paginated version of this + API. Unpaginated calls will be deprecated soon. + + PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may + contain zero results while still providing a next_page_token. Clients must + continue reading pages until next_page_token is absent, which is the only + indication that the end of results has been reached. This behavior follows + Google AIP-158 guidelines. Arguments: CATALOG_NAME: Name of parent catalog for functions of interest. diff --git a/cmd/workspace/genie/genie.go b/cmd/workspace/genie/genie.go index fa6f4ac6e8..86d36cccfd 100755 --- a/cmd/workspace/genie/genie.go +++ b/cmd/workspace/genie/genie.go @@ -200,6 +200,9 @@ func newCreateSpace() *cobra.Command { WAREHOUSE_ID: Warehouse to associate with the new space SERIALIZED_SPACE: Serialized export model for the space contents` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -534,6 +537,9 @@ func newGenerateDownloadFullQueryResult() *cobra.Command { MESSAGE_ID: Message ID ATTACHMENT_ID: Attachment ID` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -607,6 +613,9 @@ func newGetDownloadFullQueryResult() *cobra.Command { DOWNLOAD_ID: Download ID. This ID is provided by the [Generate Download endpoint](:method:genie/generateDownloadFullQueryResult)` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -1412,6 +1421,9 @@ func newUpdateSpace() *cobra.Command { Arguments: SPACE_ID: Genie space ID` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { diff --git a/cmd/workspace/git-credentials/git-credentials.go b/cmd/workspace/git-credentials/git-credentials.go index 16977d7643..fd16bc3744 100755 --- a/cmd/workspace/git-credentials/git-credentials.go +++ b/cmd/workspace/git-credentials/git-credentials.go @@ -66,7 +66,8 @@ func newCreate() *cobra.Command { cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createReq.GitUsername, "git-username", createReq.GitUsername, `The username or email provided with your Git provider account, depending on which provider you are using.`) + cmd.Flags().StringVar(&createReq.GitEmail, "git-email", createReq.GitEmail, `The authenticating email associated with your Git provider user account.`) + cmd.Flags().StringVar(&createReq.GitUsername, "git-username", createReq.GitUsername, `The username provided with your Git provider account and associated with the credential.`) cmd.Flags().BoolVar(&createReq.IsDefaultForProvider, "is-default-for-provider", createReq.IsDefaultForProvider, `if the credential is the default for the given provider.`) cmd.Flags().StringVar(&createReq.Name, "name", createReq.Name, `the name of the git credential, used for identification and ease of lookup.`) cmd.Flags().StringVar(&createReq.PersonalAccessToken, "personal-access-token", createReq.PersonalAccessToken, `The personal access token used to authenticate to the corresponding Git provider.`) @@ -339,7 +340,8 @@ func newUpdate() *cobra.Command { cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateReq.GitUsername, "git-username", updateReq.GitUsername, `The username or email provided with your Git provider account, depending on which provider you are using.`) + cmd.Flags().StringVar(&updateReq.GitEmail, "git-email", updateReq.GitEmail, `The authenticating email associated with your Git provider user account.`) + cmd.Flags().StringVar(&updateReq.GitUsername, "git-username", updateReq.GitUsername, `The username provided with your Git provider account and associated with the credential.`) cmd.Flags().BoolVar(&updateReq.IsDefaultForProvider, "is-default-for-provider", updateReq.IsDefaultForProvider, `if the credential is the default for the given provider.`) cmd.Flags().StringVar(&updateReq.Name, "name", updateReq.Name, `the name of the git credential, used for identification and ease of lookup.`) cmd.Flags().StringVar(&updateReq.PersonalAccessToken, "personal-access-token", updateReq.PersonalAccessToken, `The personal access token used to authenticate to the corresponding Git provider.`) diff --git a/cmd/workspace/lakeview-embedded/lakeview-embedded.go b/cmd/workspace/lakeview-embedded/lakeview-embedded.go index b37d454624..a37f64a94d 100755 --- a/cmd/workspace/lakeview-embedded/lakeview-embedded.go +++ b/cmd/workspace/lakeview-embedded/lakeview-embedded.go @@ -61,6 +61,9 @@ func newGetPublishedDashboardEmbedded() *cobra.Command { Arguments: DASHBOARD_ID: UUID identifying the published dashboard.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { diff --git a/cmd/workspace/libraries/libraries.go b/cmd/workspace/libraries/libraries.go index 98b114e139..faf7e36ff7 100755 --- a/cmd/workspace/libraries/libraries.go +++ b/cmd/workspace/libraries/libraries.go @@ -192,6 +192,9 @@ func newCreateDefaultBaseEnvironment() *cobra.Command { jobs. This process will asynchronously generate a cache to optimize dependency resolution.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.PreRunE = root.MustWorkspaceClient @@ -255,6 +258,9 @@ func newDeleteDefaultBaseEnvironment() *cobra.Command { may be used by downstream workloads. Please ensure that the deletion is intentional.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -302,7 +308,7 @@ func newGetDefaultBaseEnvironment() *cobra.Command { var getDefaultBaseEnvironmentReq compute.GetDefaultBaseEnvironmentRequest - cmd.Flags().StringVar(&getDefaultBaseEnvironmentReq.TraceId, "trace-id", getDefaultBaseEnvironmentReq.TraceId, ``) + cmd.Flags().StringVar(&getDefaultBaseEnvironmentReq.TraceId, "trace-id", getDefaultBaseEnvironmentReq.TraceId, `Deprecated: use ctx.requestId instead.`) cmd.Use = "get-default-base-environment ID" cmd.Short = `get a default base environment.` @@ -310,6 +316,9 @@ func newGetDefaultBaseEnvironment() *cobra.Command { Return the default base environment details for a given ID.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -432,6 +441,9 @@ func newListDefaultBaseEnvironments() *cobra.Command { List default base environments defined in the workspaces for the requested user.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -485,6 +497,9 @@ func newRefreshDefaultBaseEnvironments() *cobra.Command { will asynchronously regenerate the caches. The existing caches remains available until it expires.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.PreRunE = root.MustWorkspaceClient @@ -617,6 +632,9 @@ func newUpdateDefaultBaseEnvironment() *cobra.Command { asynchronously regenerate the cache. The existing cache remains available until it expires.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -691,6 +709,9 @@ func newUpdateDefaultDefaultBaseEnvironment() *cobra.Command { Set the default base environment for the workspace. This marks the specified DBE as the workspace default.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { diff --git a/cmd/workspace/metastores/metastores.go b/cmd/workspace/metastores/metastores.go index bd6a372f91..7a3740f718 100755 --- a/cmd/workspace/metastores/metastores.go +++ b/cmd/workspace/metastores/metastores.go @@ -421,7 +421,16 @@ func newList() *cobra.Command { Gets an array of the available metastores (as __MetastoreInfo__ objects). The caller must be an admin to retrieve this info. There is no guarantee of a - specific ordering of the elements in the array.` + specific ordering of the elements in the array. + + NOTE: we recommend using max_results=0 to use the paginated version of this + API. Unpaginated calls will be deprecated soon. + + PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may + contain zero results while still providing a next_page_token. Clients must + continue reading pages until next_page_token is absent, which is the only + indication that the end of results has been reached. This behavior follows + Google AIP-158 guidelines.` cmd.Annotations = make(map[string]string) diff --git a/cmd/workspace/pipelines/pipelines.go b/cmd/workspace/pipelines/pipelines.go index 92c4f813e3..bc3a052267 100755 --- a/cmd/workspace/pipelines/pipelines.go +++ b/cmd/workspace/pipelines/pipelines.go @@ -90,6 +90,9 @@ func newApplyEnvironment() *cobra.Command { * Applies the current pipeline environment onto the pipeline compute. The environment applied can be used by subsequent dev-mode updates.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.PreRunE = root.MustWorkspaceClient @@ -743,6 +746,9 @@ func newRestorePipeline() *cobra.Command { Arguments: PIPELINE_ID: The ID of the pipeline to restore` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.PreRunE = root.MustWorkspaceClient diff --git a/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go b/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go index 689dccd4c8..e7013ac5cd 100755 --- a/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go +++ b/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go @@ -30,8 +30,10 @@ func New() *cobra.Command { } // Add methods + cmd.AddCommand(newCreateLibrary()) cmd.AddCommand(newCreateQualityMonitor()) cmd.AddCommand(newDeleteQualityMonitor()) + cmd.AddCommand(newGetOperation()) cmd.AddCommand(newGetQualityMonitor()) cmd.AddCommand(newListQualityMonitor()) cmd.AddCommand(newUpdateQualityMonitor()) @@ -44,6 +46,91 @@ func New() *cobra.Command { return cmd } +// start create-library command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var createLibraryOverrides []func( + *cobra.Command, + *qualitymonitorv2.CreateLibraryRequest, +) + +func newCreateLibrary() *cobra.Command { + cmd := &cobra.Command{} + + var createLibraryReq qualitymonitorv2.CreateLibraryRequest + createLibraryReq.Library = qualitymonitorv2.Library{} + var createLibraryJson flags.JsonFlag + + cmd.Flags().Var(&createLibraryJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().BoolVar(&createLibraryReq.Library.ContainsSauce, "contains-sauce", createLibraryReq.Library.ContainsSauce, `Whether the resource contains sauce.`) + cmd.Flags().Int64Var(&createLibraryReq.Library.LegCount, "leg-count", createLibraryReq.Library.LegCount, `Count of legs in the resource.`) + + cmd.Use = "create-library NAME" + cmd.Short = `Create a Library Resource.` + cmd.Long = `Create a Library Resource. + + Arguments: + NAME: Name of the Resource. Must contain only: - alphanumeric characters - + underscores - hyphens + + Note: The name must be unique within the scope of the resource.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + if cmd.Flags().Changed("json") { + err := root.ExactArgs(0)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'name' in your JSON input") + } + return nil + } + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := createLibraryJson.Unmarshal(&createLibraryReq.Library) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + if !cmd.Flags().Changed("json") { + createLibraryReq.Library.Name = args[0] + } + + response, err := w.QualityMonitorV2.CreateLibrary(ctx, createLibraryReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range createLibraryOverrides { + fn(cmd, &createLibraryReq) + } + + return cmd +} + // start create-quality-monitor command // Slice with functions to override default command behavior. @@ -189,6 +276,60 @@ func newDeleteQualityMonitor() *cobra.Command { return cmd } +// start get-operation command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var getOperationOverrides []func( + *cobra.Command, + *qualitymonitorv2.GetOperationRequest, +) + +func newGetOperation() *cobra.Command { + cmd := &cobra.Command{} + + var getOperationReq qualitymonitorv2.GetOperationRequest + + cmd.Use = "get-operation NAME" + cmd.Short = `Get a Library Operation.` + cmd.Long = `Get a Library Operation. + + Arguments: + NAME: The name of the operation resource.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + getOperationReq.Name = args[0] + + response, err := w.QualityMonitorV2.GetOperation(ctx, getOperationReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range getOperationOverrides { + fn(cmd, &getOperationReq) + } + + return cmd +} + // start get-quality-monitor command // Slice with functions to override default command behavior. diff --git a/cmd/workspace/query-visualizations-legacy/query-visualizations-legacy.go b/cmd/workspace/query-visualizations-legacy/query-visualizations-legacy.go index a7852161ff..f66fe2b615 100755 --- a/cmd/workspace/query-visualizations-legacy/query-visualizations-legacy.go +++ b/cmd/workspace/query-visualizations-legacy/query-visualizations-legacy.go @@ -211,7 +211,7 @@ func newUpdate() *cobra.Command { cmd.Flags().StringVar(&updateReq.Type, "type", updateReq.Type, `The type of visualization: chart, table, pivot table, and so on.`) cmd.Flags().StringVar(&updateReq.UpdatedAt, "updated-at", updateReq.UpdatedAt, ``) - cmd.Use = "update ID" + cmd.Use = "update" cmd.Short = `Edit existing visualization.` cmd.Long = `Edit existing visualization. @@ -220,15 +220,12 @@ func newUpdate() *cobra.Command { **Note**: A new version of the Databricks SQL API is now available. Please use :method:queryvisualizations/update instead. [Learn more] - [Learn more]: https://docs.databricks.com/en/sql/dbsql-api-latest.html - - Arguments: - ID: The UUID for this visualization.` + [Learn more]: https://docs.databricks.com/en/sql/dbsql-api-latest.html` cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { - check := root.ExactArgs(1) + check := root.ExactArgs(0) return check(cmd, args) } @@ -249,7 +246,6 @@ func newUpdate() *cobra.Command { } } } - updateReq.Id = args[0] response, err := w.QueryVisualizationsLegacy.Update(ctx, updateReq) if err != nil { diff --git a/cmd/workspace/schemas/schemas.go b/cmd/workspace/schemas/schemas.go index 0c73eb5ea4..7757127c33 100755 --- a/cmd/workspace/schemas/schemas.go +++ b/cmd/workspace/schemas/schemas.go @@ -284,6 +284,15 @@ func newList() *cobra.Command { catalog will be retrieved. Otherwise, only schemas owned by the caller (or for which the caller has the **USE_SCHEMA** privilege) will be retrieved. There is no guarantee of a specific ordering of the elements in the array. + + NOTE: we recommend using max_results=0 to use the paginated version of this + API. Unpaginated calls will be deprecated soon. + + PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may + contain zero results while still providing a next_page_token. Clients must + continue reading pages until next_page_token is absent, which is the only + indication that the end of results has been reached. This behavior follows + Google AIP-158 guidelines. Arguments: CATALOG_NAME: Parent catalog for schemas of interest.` diff --git a/cmd/workspace/shares/shares.go b/cmd/workspace/shares/shares.go index bc3bcdb35f..001781aff4 100755 --- a/cmd/workspace/shares/shares.go +++ b/cmd/workspace/shares/shares.go @@ -330,7 +330,7 @@ func newSharePermissions() *cobra.Command { metastore admin or the owner of the share. Arguments: - NAME: The name of the share.` + NAME: The name of the Recipient.` cmd.Annotations = make(map[string]string) diff --git a/cmd/workspace/storage-credentials/storage-credentials.go b/cmd/workspace/storage-credentials/storage-credentials.go index 2d24a4f1c1..ac8c5cb6c3 100755 --- a/cmd/workspace/storage-credentials/storage-credentials.go +++ b/cmd/workspace/storage-credentials/storage-credentials.go @@ -293,7 +293,16 @@ func newList() *cobra.Command { The array is limited to only those storage credentials the caller has permission to access. If the caller is a metastore admin, retrieval of credentials is unrestricted. There is no guarantee of a specific ordering of - the elements in the array.` + the elements in the array. + + NOTE: we recommend using max_results=0 to use the paginated version of this + API. Unpaginated calls will be deprecated soon. + + PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may + contain zero results while still providing a next_page_token. Clients must + continue reading pages until next_page_token is absent, which is the only + indication that the end of results has been reached. This behavior follows + Google AIP-158 guidelines.` cmd.Annotations = make(map[string]string) diff --git a/cmd/workspace/system-schemas/system-schemas.go b/cmd/workspace/system-schemas/system-schemas.go index e88ee60489..f0f21b203a 100755 --- a/cmd/workspace/system-schemas/system-schemas.go +++ b/cmd/workspace/system-schemas/system-schemas.go @@ -200,6 +200,15 @@ func newList() *cobra.Command { Gets an array of system schemas for a metastore. The caller must be an account admin or a metastore admin. + + NOTE: we recommend using max_results=0 to use the paginated version of this + API. Unpaginated calls will be deprecated soon. + + PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may + contain zero results while still providing a next_page_token. Clients must + continue reading pages until next_page_token is absent, which is the only + indication that the end of results has been reached. This behavior follows + Google AIP-158 guidelines. Arguments: METASTORE_ID: The ID for the metastore in which the system schema resides.` diff --git a/cmd/workspace/tables/tables.go b/cmd/workspace/tables/tables.go index 5ae07f0db3..af6db516f2 100755 --- a/cmd/workspace/tables/tables.go +++ b/cmd/workspace/tables/tables.go @@ -450,6 +450,15 @@ func newList() *cobra.Command { be the owner or have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema. There is no guarantee of a specific ordering of the elements in the array. + + NOTE: we recommend using max_results=0 to use the paginated version of this + API. Unpaginated calls will be deprecated soon. + + PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may + contain zero results while still providing a next_page_token. Clients must + continue reading pages until next_page_token is absent, which is the only + indication that the end of results has been reached. This behavior follows + Google AIP-158 guidelines. Arguments: CATALOG_NAME: Name of parent catalog for tables of interest. diff --git a/cmd/workspace/vector-search-indexes/vector-search-indexes.go b/cmd/workspace/vector-search-indexes/vector-search-indexes.go index 345ef982da..383e0b66f7 100755 --- a/cmd/workspace/vector-search-indexes/vector-search-indexes.go +++ b/cmd/workspace/vector-search-indexes/vector-search-indexes.go @@ -707,6 +707,9 @@ func newUpdateIndexBudgetPolicy() *cobra.Command { Arguments: INDEX_NAME: Name of the vector search index` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { diff --git a/cmd/workspace/workspace-iam-v2/workspace-iam-v2.go b/cmd/workspace/workspace-iam-v2/workspace-iam-v2.go index 60d71eed06..1a69f68d44 100755 --- a/cmd/workspace/workspace-iam-v2/workspace-iam-v2.go +++ b/cmd/workspace/workspace-iam-v2/workspace-iam-v2.go @@ -90,6 +90,9 @@ func newCreateGroupProxy() *cobra.Command { TODO: Write description later when this method is implemented` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -163,6 +166,9 @@ func newCreateServicePrincipalProxy() *cobra.Command { TODO: Write description later when this method is implemented` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -238,6 +244,9 @@ func newCreateUserProxy() *cobra.Command { Arguments: USERNAME: Username/email of the user.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -319,6 +328,9 @@ func newCreateWorkspaceAccessDetailLocal() *cobra.Command { TODO: Write description later when this method is implemented` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -386,6 +398,9 @@ func newDeleteGroupProxy() *cobra.Command { Arguments: INTERNAL_ID: Required. Internal ID of the group in Databricks.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -445,6 +460,9 @@ func newDeleteServicePrincipalProxy() *cobra.Command { Arguments: INTERNAL_ID: Required. Internal ID of the service principal in Databricks.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -504,6 +522,9 @@ func newDeleteUserProxy() *cobra.Command { Arguments: INTERNAL_ID: Required. Internal ID of the user in Databricks.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -563,6 +584,9 @@ func newDeleteWorkspaceAccessDetailLocal() *cobra.Command { Arguments: PRINCIPAL_ID: Required. ID of the principal in Databricks.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -622,6 +646,9 @@ func newGetGroupProxy() *cobra.Command { Arguments: INTERNAL_ID: Required. Internal ID of the group in Databricks.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -681,6 +708,9 @@ func newGetServicePrincipalProxy() *cobra.Command { Arguments: INTERNAL_ID: Required. Internal ID of the service principal in Databricks.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -740,6 +770,9 @@ func newGetUserProxy() *cobra.Command { Arguments: INTERNAL_ID: Required. Internal ID of the user in Databricks.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -866,6 +899,9 @@ func newListGroupsProxy() *cobra.Command { TODO: Write description later when this method is implemented` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -920,6 +956,9 @@ func newListServicePrincipalsProxy() *cobra.Command { TODO: Write description later when this method is implemented` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -974,6 +1013,9 @@ func newListUsersProxy() *cobra.Command { TODO: Write description later when this method is implemented` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -1028,6 +1070,9 @@ func newListWorkspaceAccessDetailsLocal() *cobra.Command { TODO: Write description later when this method is implemented` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -1337,6 +1382,9 @@ func newUpdateGroupProxy() *cobra.Command { INTERNAL_ID: Required. Internal ID of the group in Databricks. UPDATE_MASK: Optional. The list of fields to update.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -1419,6 +1467,9 @@ func newUpdateServicePrincipalProxy() *cobra.Command { INTERNAL_ID: Required. Internal ID of the service principal in Databricks. UPDATE_MASK: Optional. The list of fields to update.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -1501,6 +1552,9 @@ func newUpdateUserProxy() *cobra.Command { UPDATE_MASK: Optional. The list of fields to update. USERNAME: Username/email of the user.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -1591,6 +1645,9 @@ func newUpdateWorkspaceAccessDetailLocal() *cobra.Command { PRINCIPAL_ID: Required. ID of the principal in Databricks. UPDATE_MASK: Optional. The list of fields to update.` + // This command is being previewed; hide from help output. + cmd.Hidden = true + cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -1640,4 +1697,4 @@ func newUpdateWorkspaceAccessDetailLocal() *cobra.Command { return cmd } -// end service workspace_iamV2 +// end service WorkspaceIamV2 From 86fa116197caed52ba4a5d5e6f4fbb86faede8a2 Mon Sep 17 00:00:00 2001 From: Parth Bansal Date: Thu, 9 Oct 2025 17:12:34 +0000 Subject: [PATCH 3/9] update --- .../quality-monitor-v2/quality-monitor-v2.go | 350 ------------------ 1 file changed, 350 deletions(-) diff --git a/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go b/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go index e7013ac5cd..dd6b3be99a 100755 --- a/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go +++ b/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go @@ -31,12 +31,7 @@ func New() *cobra.Command { // Add methods cmd.AddCommand(newCreateLibrary()) - cmd.AddCommand(newCreateQualityMonitor()) - cmd.AddCommand(newDeleteQualityMonitor()) cmd.AddCommand(newGetOperation()) - cmd.AddCommand(newGetQualityMonitor()) - cmd.AddCommand(newListQualityMonitor()) - cmd.AddCommand(newUpdateQualityMonitor()) // Apply optional overrides to this command. for _, fn := range cmdOverrides { @@ -131,151 +126,6 @@ func newCreateLibrary() *cobra.Command { return cmd } -// start create-quality-monitor command - -// Slice with functions to override default command behavior. -// Functions can be added from the `init()` function in manually curated files in this directory. -var createQualityMonitorOverrides []func( - *cobra.Command, - *qualitymonitorv2.CreateQualityMonitorRequest, -) - -func newCreateQualityMonitor() *cobra.Command { - cmd := &cobra.Command{} - - var createQualityMonitorReq qualitymonitorv2.CreateQualityMonitorRequest - createQualityMonitorReq.QualityMonitor = qualitymonitorv2.QualityMonitor{} - var createQualityMonitorJson flags.JsonFlag - - cmd.Flags().Var(&createQualityMonitorJson, "json", `either inline JSON string or @path/to/file.json with request body`) - - // TODO: complex arg: anomaly_detection_config - - cmd.Use = "create-quality-monitor OBJECT_TYPE OBJECT_ID" - cmd.Short = `Create a quality monitor.` - cmd.Long = `Create a quality monitor. - - Create a quality monitor on UC object - - Arguments: - OBJECT_TYPE: The type of the monitored object. Can be one of the following: schema. - OBJECT_ID: The uuid of the request object. For example, schema id.` - - cmd.Annotations = make(map[string]string) - - cmd.Args = func(cmd *cobra.Command, args []string) error { - if cmd.Flags().Changed("json") { - err := root.ExactArgs(0)(cmd, args) - if err != nil { - return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'object_type', 'object_id' in your JSON input") - } - return nil - } - check := root.ExactArgs(2) - return check(cmd, args) - } - - cmd.PreRunE = root.MustWorkspaceClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - w := cmdctx.WorkspaceClient(ctx) - - if cmd.Flags().Changed("json") { - diags := createQualityMonitorJson.Unmarshal(&createQualityMonitorReq.QualityMonitor) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) - if err != nil { - return err - } - } - } - if !cmd.Flags().Changed("json") { - createQualityMonitorReq.QualityMonitor.ObjectType = args[0] - } - if !cmd.Flags().Changed("json") { - createQualityMonitorReq.QualityMonitor.ObjectId = args[1] - } - - response, err := w.QualityMonitorV2.CreateQualityMonitor(ctx, createQualityMonitorReq) - if err != nil { - return err - } - return cmdio.Render(ctx, response) - } - - // Disable completions since they are not applicable. - // Can be overridden by manual implementation in `override.go`. - cmd.ValidArgsFunction = cobra.NoFileCompletions - - // Apply optional overrides to this command. - for _, fn := range createQualityMonitorOverrides { - fn(cmd, &createQualityMonitorReq) - } - - return cmd -} - -// start delete-quality-monitor command - -// Slice with functions to override default command behavior. -// Functions can be added from the `init()` function in manually curated files in this directory. -var deleteQualityMonitorOverrides []func( - *cobra.Command, - *qualitymonitorv2.DeleteQualityMonitorRequest, -) - -func newDeleteQualityMonitor() *cobra.Command { - cmd := &cobra.Command{} - - var deleteQualityMonitorReq qualitymonitorv2.DeleteQualityMonitorRequest - - cmd.Use = "delete-quality-monitor OBJECT_TYPE OBJECT_ID" - cmd.Short = `Delete a quality monitor.` - cmd.Long = `Delete a quality monitor. - - Delete a quality monitor on UC object - - Arguments: - OBJECT_TYPE: The type of the monitored object. Can be one of the following: schema. - OBJECT_ID: The uuid of the request object. For example, schema id.` - - cmd.Annotations = make(map[string]string) - - cmd.Args = func(cmd *cobra.Command, args []string) error { - check := root.ExactArgs(2) - return check(cmd, args) - } - - cmd.PreRunE = root.MustWorkspaceClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - w := cmdctx.WorkspaceClient(ctx) - - deleteQualityMonitorReq.ObjectType = args[0] - deleteQualityMonitorReq.ObjectId = args[1] - - err = w.QualityMonitorV2.DeleteQualityMonitor(ctx, deleteQualityMonitorReq) - if err != nil { - return err - } - return nil - } - - // Disable completions since they are not applicable. - // Can be overridden by manual implementation in `override.go`. - cmd.ValidArgsFunction = cobra.NoFileCompletions - - // Apply optional overrides to this command. - for _, fn := range deleteQualityMonitorOverrides { - fn(cmd, &deleteQualityMonitorReq) - } - - return cmd -} - // start get-operation command // Slice with functions to override default command behavior. @@ -330,204 +180,4 @@ func newGetOperation() *cobra.Command { return cmd } -// start get-quality-monitor command - -// Slice with functions to override default command behavior. -// Functions can be added from the `init()` function in manually curated files in this directory. -var getQualityMonitorOverrides []func( - *cobra.Command, - *qualitymonitorv2.GetQualityMonitorRequest, -) - -func newGetQualityMonitor() *cobra.Command { - cmd := &cobra.Command{} - - var getQualityMonitorReq qualitymonitorv2.GetQualityMonitorRequest - - cmd.Use = "get-quality-monitor OBJECT_TYPE OBJECT_ID" - cmd.Short = `Read a quality monitor.` - cmd.Long = `Read a quality monitor. - - Read a quality monitor on UC object - - Arguments: - OBJECT_TYPE: The type of the monitored object. Can be one of the following: schema. - OBJECT_ID: The uuid of the request object. For example, schema id.` - - cmd.Annotations = make(map[string]string) - - cmd.Args = func(cmd *cobra.Command, args []string) error { - check := root.ExactArgs(2) - return check(cmd, args) - } - - cmd.PreRunE = root.MustWorkspaceClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - w := cmdctx.WorkspaceClient(ctx) - - getQualityMonitorReq.ObjectType = args[0] - getQualityMonitorReq.ObjectId = args[1] - - response, err := w.QualityMonitorV2.GetQualityMonitor(ctx, getQualityMonitorReq) - if err != nil { - return err - } - return cmdio.Render(ctx, response) - } - - // Disable completions since they are not applicable. - // Can be overridden by manual implementation in `override.go`. - cmd.ValidArgsFunction = cobra.NoFileCompletions - - // Apply optional overrides to this command. - for _, fn := range getQualityMonitorOverrides { - fn(cmd, &getQualityMonitorReq) - } - - return cmd -} - -// start list-quality-monitor command - -// Slice with functions to override default command behavior. -// Functions can be added from the `init()` function in manually curated files in this directory. -var listQualityMonitorOverrides []func( - *cobra.Command, - *qualitymonitorv2.ListQualityMonitorRequest, -) - -func newListQualityMonitor() *cobra.Command { - cmd := &cobra.Command{} - - var listQualityMonitorReq qualitymonitorv2.ListQualityMonitorRequest - - cmd.Flags().IntVar(&listQualityMonitorReq.PageSize, "page-size", listQualityMonitorReq.PageSize, ``) - cmd.Flags().StringVar(&listQualityMonitorReq.PageToken, "page-token", listQualityMonitorReq.PageToken, ``) - - cmd.Use = "list-quality-monitor" - cmd.Short = `List quality monitors.` - cmd.Long = `List quality monitors. - - (Unimplemented) List quality monitors` - - cmd.Annotations = make(map[string]string) - - cmd.Args = func(cmd *cobra.Command, args []string) error { - check := root.ExactArgs(0) - return check(cmd, args) - } - - cmd.PreRunE = root.MustWorkspaceClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - w := cmdctx.WorkspaceClient(ctx) - - response := w.QualityMonitorV2.ListQualityMonitor(ctx, listQualityMonitorReq) - return cmdio.RenderIterator(ctx, response) - } - - // Disable completions since they are not applicable. - // Can be overridden by manual implementation in `override.go`. - cmd.ValidArgsFunction = cobra.NoFileCompletions - - // Apply optional overrides to this command. - for _, fn := range listQualityMonitorOverrides { - fn(cmd, &listQualityMonitorReq) - } - - return cmd -} - -// start update-quality-monitor command - -// Slice with functions to override default command behavior. -// Functions can be added from the `init()` function in manually curated files in this directory. -var updateQualityMonitorOverrides []func( - *cobra.Command, - *qualitymonitorv2.UpdateQualityMonitorRequest, -) - -func newUpdateQualityMonitor() *cobra.Command { - cmd := &cobra.Command{} - - var updateQualityMonitorReq qualitymonitorv2.UpdateQualityMonitorRequest - updateQualityMonitorReq.QualityMonitor = qualitymonitorv2.QualityMonitor{} - var updateQualityMonitorJson flags.JsonFlag - - cmd.Flags().Var(&updateQualityMonitorJson, "json", `either inline JSON string or @path/to/file.json with request body`) - - // TODO: complex arg: anomaly_detection_config - - cmd.Use = "update-quality-monitor OBJECT_TYPE OBJECT_ID OBJECT_TYPE OBJECT_ID" - cmd.Short = `Update a quality monitor.` - cmd.Long = `Update a quality monitor. - - (Unimplemented) Update a quality monitor on UC object - - Arguments: - OBJECT_TYPE: The type of the monitored object. Can be one of the following: schema. - OBJECT_ID: The uuid of the request object. For example, schema id. - OBJECT_TYPE: The type of the monitored object. Can be one of the following: schema. - OBJECT_ID: The uuid of the request object. For example, schema id.` - - cmd.Annotations = make(map[string]string) - - cmd.Args = func(cmd *cobra.Command, args []string) error { - if cmd.Flags().Changed("json") { - err := root.ExactArgs(2)(cmd, args) - if err != nil { - return fmt.Errorf("when --json flag is specified, provide only OBJECT_TYPE, OBJECT_ID as positional arguments. Provide 'object_type', 'object_id' in your JSON input") - } - return nil - } - check := root.ExactArgs(4) - return check(cmd, args) - } - - cmd.PreRunE = root.MustWorkspaceClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - w := cmdctx.WorkspaceClient(ctx) - - if cmd.Flags().Changed("json") { - diags := updateQualityMonitorJson.Unmarshal(&updateQualityMonitorReq.QualityMonitor) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) - if err != nil { - return err - } - } - } - updateQualityMonitorReq.ObjectType = args[0] - updateQualityMonitorReq.ObjectId = args[1] - if !cmd.Flags().Changed("json") { - updateQualityMonitorReq.QualityMonitor.ObjectType = args[2] - } - if !cmd.Flags().Changed("json") { - updateQualityMonitorReq.QualityMonitor.ObjectId = args[3] - } - - response, err := w.QualityMonitorV2.UpdateQualityMonitor(ctx, updateQualityMonitorReq) - if err != nil { - return err - } - return cmdio.Render(ctx, response) - } - - // Disable completions since they are not applicable. - // Can be overridden by manual implementation in `override.go`. - cmd.ValidArgsFunction = cobra.NoFileCompletions - - // Apply optional overrides to this command. - for _, fn := range updateQualityMonitorOverrides { - fn(cmd, &updateQualityMonitorReq) - } - - return cmd -} - // end service QualityMonitorV2 From f0cfd3d29c01d4d56ce525b6a9dc25725d64096b Mon Sep 17 00:00:00 2001 From: Parth Bansal Date: Thu, 9 Oct 2025 21:31:46 +0000 Subject: [PATCH 4/9] update --- .../out.requests.txt | 29 ++++ .../create-library-default-wait/out.test.toml | 5 + .../create-library-default-wait/output.txt | 8 + .../create-library-default-wait/script | 1 + .../create-library-default-wait/test.toml | 59 ++++++++ .../create-library-no-wait/out.requests.txt | 29 ++++ .../create-library-no-wait/out.test.toml | 5 + .../create-library-no-wait/output.txt | 10 ++ .../create-library-no-wait/script | 1 + .../create-library-no-wait/test.toml | 44 ++++++ .../create-library-status/out.requests.txt | 12 ++ .../create-library-status/out.test.toml | 5 + .../create-library-status/output.txt | 10 ++ .../create-library-status/script | 1 + .../create-library-status/test.toml | 31 ++++ .../create-library-wait/out.requests.txt | 24 +++ .../create-library-wait/out.test.toml | 5 + .../create-library-wait/output.txt | 8 + .../create-library-wait/script | 1 + .../create-library-wait/test.toml | 46 ++++++ .../quality-monitor-v2/quality-monitor-v2.go | 138 +++++++++++++++++- 21 files changed, 468 insertions(+), 4 deletions(-) create mode 100644 acceptance/workspace/quality-monitor-v2/create-library-default-wait/out.requests.txt create mode 100644 acceptance/workspace/quality-monitor-v2/create-library-default-wait/out.test.toml create mode 100644 acceptance/workspace/quality-monitor-v2/create-library-default-wait/output.txt create mode 100644 acceptance/workspace/quality-monitor-v2/create-library-default-wait/script create mode 100644 acceptance/workspace/quality-monitor-v2/create-library-default-wait/test.toml create mode 100644 acceptance/workspace/quality-monitor-v2/create-library-no-wait/out.requests.txt create mode 100644 acceptance/workspace/quality-monitor-v2/create-library-no-wait/out.test.toml create mode 100644 acceptance/workspace/quality-monitor-v2/create-library-no-wait/output.txt create mode 100644 acceptance/workspace/quality-monitor-v2/create-library-no-wait/script create mode 100644 acceptance/workspace/quality-monitor-v2/create-library-no-wait/test.toml create mode 100644 acceptance/workspace/quality-monitor-v2/create-library-status/out.requests.txt create mode 100644 acceptance/workspace/quality-monitor-v2/create-library-status/out.test.toml create mode 100644 acceptance/workspace/quality-monitor-v2/create-library-status/output.txt create mode 100644 acceptance/workspace/quality-monitor-v2/create-library-status/script create mode 100644 acceptance/workspace/quality-monitor-v2/create-library-status/test.toml create mode 100644 acceptance/workspace/quality-monitor-v2/create-library-wait/out.requests.txt create mode 100644 acceptance/workspace/quality-monitor-v2/create-library-wait/out.test.toml create mode 100644 acceptance/workspace/quality-monitor-v2/create-library-wait/output.txt create mode 100644 acceptance/workspace/quality-monitor-v2/create-library-wait/script create mode 100644 acceptance/workspace/quality-monitor-v2/create-library-wait/test.toml diff --git a/acceptance/workspace/quality-monitor-v2/create-library-default-wait/out.requests.txt b/acceptance/workspace/quality-monitor-v2/create-library-default-wait/out.requests.txt new file mode 100644 index 0000000000..9e3540861f --- /dev/null +++ b/acceptance/workspace/quality-monitor-v2/create-library-default-wait/out.requests.txt @@ -0,0 +1,29 @@ +{ + "headers": { + "Authorization": [ + "Bearer [DATABRICKS_TOKEN]" + ], + "User-Agent": [ + "cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/quality-monitor-v2_create-library cmd-exec-id/[UUID] auth/pat" + ] + }, + "method": "POST", + "path": "/api/3.0/library", + "body": { + "contains_sauce": true, + "leg_count": 6, + "name": "test-library-default" + } +} +{ + "headers": { + "Authorization": [ + "Bearer [DATABRICKS_TOKEN]" + ], + "User-Agent": [ + "cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/quality-monitor-v2_create-library cmd-exec-id/[UUID] sdk-feature/long-running auth/pat" + ] + }, + "method": "GET", + "path": "/api/3.0/operations/operations/test-library-default-op" +} diff --git a/acceptance/workspace/quality-monitor-v2/create-library-default-wait/out.test.toml b/acceptance/workspace/quality-monitor-v2/create-library-default-wait/out.test.toml new file mode 100644 index 0000000000..e092fd5ed6 --- /dev/null +++ b/acceptance/workspace/quality-monitor-v2/create-library-default-wait/out.test.toml @@ -0,0 +1,5 @@ +Local = true +Cloud = false + +[EnvMatrix] + DATABRICKS_BUNDLE_ENGINE = ["terraform", "direct-exp"] diff --git a/acceptance/workspace/quality-monitor-v2/create-library-default-wait/output.txt b/acceptance/workspace/quality-monitor-v2/create-library-default-wait/output.txt new file mode 100644 index 0000000000..b509784dd4 --- /dev/null +++ b/acceptance/workspace/quality-monitor-v2/create-library-default-wait/output.txt @@ -0,0 +1,8 @@ + +>>> [CLI] quality-monitor-v2 create-library test-library-default --leg-count 6 --contains-sauce +{ + "contains_sauce":true, + "created_at":[NUMID], + "leg_count":6, + "name":"test-library-default" +} diff --git a/acceptance/workspace/quality-monitor-v2/create-library-default-wait/script b/acceptance/workspace/quality-monitor-v2/create-library-default-wait/script new file mode 100644 index 0000000000..2cd87f470e --- /dev/null +++ b/acceptance/workspace/quality-monitor-v2/create-library-default-wait/script @@ -0,0 +1 @@ +trace $CLI quality-monitor-v2 create-library test-library-default --leg-count 6 --contains-sauce diff --git a/acceptance/workspace/quality-monitor-v2/create-library-default-wait/test.toml b/acceptance/workspace/quality-monitor-v2/create-library-default-wait/test.toml new file mode 100644 index 0000000000..94b4296b54 --- /dev/null +++ b/acceptance/workspace/quality-monitor-v2/create-library-default-wait/test.toml @@ -0,0 +1,59 @@ +RecordRequests = true +IncludeRequestHeaders = ["Authorization", "User-Agent"] + +[[Server]] +Pattern = "POST /api/3.0/library" +Response.Body = ''' +{ + "name": "operations/test-library-default-op", + "done": false, + "metadata": { + "created_at": 1234567890, + "library_name": "test-library-default" + } +} +''' + +[[Server]] +Pattern = "GET /api/3.0/operations/operations/test-library-default-op" +Response.Body = ''' +{ + "name": "operations/test-library-default-op", + "done": false, + "metadata": { + "created_at": 1234567890, + "library_name": "test-library-default" + } +} +''' + +[[Server]] +Pattern = "GET /api/3.0/operations/operations/test-library-default-op" +Response.Body = ''' +{ + "name": "operations/test-library-default-op", + "done": true, + "response": { + "name": "test-library-default", + "leg_count": 6, + "contains_sauce": true, + "created_at": 1234567890 + } +} +''' + +[[Repls]] +Old = "(linux|darwin|windows)" +New = "[OS]" + +[[Repls]] +Old = " upstream/[A-Za-z0-9.-]+" +New = "" + +[[Repls]] +Old = " upstream-version/[A-Za-z0-9.-]+" +New = "" + +[[Repls]] +Old = " cicd/[A-Za-z0-9.-]+" +New = "" diff --git a/acceptance/workspace/quality-monitor-v2/create-library-no-wait/out.requests.txt b/acceptance/workspace/quality-monitor-v2/create-library-no-wait/out.requests.txt new file mode 100644 index 0000000000..7d295ed3b3 --- /dev/null +++ b/acceptance/workspace/quality-monitor-v2/create-library-no-wait/out.requests.txt @@ -0,0 +1,29 @@ +{ + "headers": { + "Authorization": [ + "Bearer [DATABRICKS_TOKEN]" + ], + "User-Agent": [ + "cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/quality-monitor-v2_create-library cmd-exec-id/[UUID] auth/pat" + ] + }, + "method": "POST", + "path": "/api/3.0/library", + "body": { + "contains_sauce": true, + "leg_count": 4, + "name": "test-library" + } +} +{ + "headers": { + "Authorization": [ + "Bearer [DATABRICKS_TOKEN]" + ], + "User-Agent": [ + "cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/quality-monitor-v2_create-library cmd-exec-id/[UUID] auth/pat" + ] + }, + "method": "GET", + "path": "/api/3.0/operations/operations/test-library-op-123" +} diff --git a/acceptance/workspace/quality-monitor-v2/create-library-no-wait/out.test.toml b/acceptance/workspace/quality-monitor-v2/create-library-no-wait/out.test.toml new file mode 100644 index 0000000000..e092fd5ed6 --- /dev/null +++ b/acceptance/workspace/quality-monitor-v2/create-library-no-wait/out.test.toml @@ -0,0 +1,5 @@ +Local = true +Cloud = false + +[EnvMatrix] + DATABRICKS_BUNDLE_ENGINE = ["terraform", "direct-exp"] diff --git a/acceptance/workspace/quality-monitor-v2/create-library-no-wait/output.txt b/acceptance/workspace/quality-monitor-v2/create-library-no-wait/output.txt new file mode 100644 index 0000000000..481b830519 --- /dev/null +++ b/acceptance/workspace/quality-monitor-v2/create-library-no-wait/output.txt @@ -0,0 +1,10 @@ + +>>> [CLI] quality-monitor-v2 create-library test-library --leg-count 4 --contains-sauce --no-wait +{ + "done":false, + "metadata": { + "created_at":[NUMID], + "library_name":"test-library" + }, + "name":"operations/test-library-op-123" +} diff --git a/acceptance/workspace/quality-monitor-v2/create-library-no-wait/script b/acceptance/workspace/quality-monitor-v2/create-library-no-wait/script new file mode 100644 index 0000000000..dfa48c4eac --- /dev/null +++ b/acceptance/workspace/quality-monitor-v2/create-library-no-wait/script @@ -0,0 +1 @@ +trace $CLI quality-monitor-v2 create-library test-library --leg-count 4 --contains-sauce --no-wait diff --git a/acceptance/workspace/quality-monitor-v2/create-library-no-wait/test.toml b/acceptance/workspace/quality-monitor-v2/create-library-no-wait/test.toml new file mode 100644 index 0000000000..df4e6be4f6 --- /dev/null +++ b/acceptance/workspace/quality-monitor-v2/create-library-no-wait/test.toml @@ -0,0 +1,44 @@ +RecordRequests = true +IncludeRequestHeaders = ["Authorization", "User-Agent"] + +[[Server]] +Pattern = "POST /api/3.0/library" +Response.Body = ''' +{ + "name": "operations/test-library-op-123", + "done": false, + "metadata": { + "created_at": 1234567890, + "library_name": "test-library" + } +} +''' + +[[Server]] +Pattern = "GET /api/3.0/operations/operations/test-library-op-123" +Response.Body = ''' +{ + "name": "operations/test-library-op-123", + "done": false, + "metadata": { + "created_at": 1234567890, + "library_name": "test-library" + } +} +''' + +[[Repls]] +Old = "(linux|darwin|windows)" +New = "[OS]" + +[[Repls]] +Old = " upstream/[A-Za-z0-9.-]+" +New = "" + +[[Repls]] +Old = " upstream-version/[A-Za-z0-9.-]+" +New = "" + +[[Repls]] +Old = " cicd/[A-Za-z0-9.-]+" +New = "" diff --git a/acceptance/workspace/quality-monitor-v2/create-library-status/out.requests.txt b/acceptance/workspace/quality-monitor-v2/create-library-status/out.requests.txt new file mode 100644 index 0000000000..ffdf61950d --- /dev/null +++ b/acceptance/workspace/quality-monitor-v2/create-library-status/out.requests.txt @@ -0,0 +1,12 @@ +{ + "headers": { + "Authorization": [ + "Bearer [DATABRICKS_TOKEN]" + ], + "User-Agent": [ + "cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/quality-monitor-v2_create-library cmd-exec-id/[UUID] auth/pat" + ] + }, + "method": "GET", + "path": "/api/3.0/operations/operations/test-library-op-789" +} diff --git a/acceptance/workspace/quality-monitor-v2/create-library-status/out.test.toml b/acceptance/workspace/quality-monitor-v2/create-library-status/out.test.toml new file mode 100644 index 0000000000..e092fd5ed6 --- /dev/null +++ b/acceptance/workspace/quality-monitor-v2/create-library-status/out.test.toml @@ -0,0 +1,5 @@ +Local = true +Cloud = false + +[EnvMatrix] + DATABRICKS_BUNDLE_ENGINE = ["terraform", "direct-exp"] diff --git a/acceptance/workspace/quality-monitor-v2/create-library-status/output.txt b/acceptance/workspace/quality-monitor-v2/create-library-status/output.txt new file mode 100644 index 0000000000..cbce2653d7 --- /dev/null +++ b/acceptance/workspace/quality-monitor-v2/create-library-status/output.txt @@ -0,0 +1,10 @@ + +>>> [CLI] quality-monitor-v2 create-library operations/test-library-op-789 --status +{ + "done":false, + "metadata": { + "created_at":[NUMID], + "library_name":"test-library-status" + }, + "name":"operations/test-library-op-789" +} diff --git a/acceptance/workspace/quality-monitor-v2/create-library-status/script b/acceptance/workspace/quality-monitor-v2/create-library-status/script new file mode 100644 index 0000000000..8dc3b0e6bc --- /dev/null +++ b/acceptance/workspace/quality-monitor-v2/create-library-status/script @@ -0,0 +1 @@ +trace $CLI quality-monitor-v2 create-library operations/test-library-op-789 --status diff --git a/acceptance/workspace/quality-monitor-v2/create-library-status/test.toml b/acceptance/workspace/quality-monitor-v2/create-library-status/test.toml new file mode 100644 index 0000000000..e9db77b6af --- /dev/null +++ b/acceptance/workspace/quality-monitor-v2/create-library-status/test.toml @@ -0,0 +1,31 @@ +RecordRequests = true +IncludeRequestHeaders = ["Authorization", "User-Agent"] + +[[Server]] +Pattern = "GET /api/3.0/operations/operations/test-library-op-789" +Response.Body = ''' +{ + "name": "operations/test-library-op-789", + "done": false, + "metadata": { + "created_at": 1234567890, + "library_name": "test-library-status" + } +} +''' + +[[Repls]] +Old = "(linux|darwin|windows)" +New = "[OS]" + +[[Repls]] +Old = " upstream/[A-Za-z0-9.-]+" +New = "" + +[[Repls]] +Old = " upstream-version/[A-Za-z0-9.-]+" +New = "" + +[[Repls]] +Old = " cicd/[A-Za-z0-9.-]+" +New = "" diff --git a/acceptance/workspace/quality-monitor-v2/create-library-wait/out.requests.txt b/acceptance/workspace/quality-monitor-v2/create-library-wait/out.requests.txt new file mode 100644 index 0000000000..57854173b2 --- /dev/null +++ b/acceptance/workspace/quality-monitor-v2/create-library-wait/out.requests.txt @@ -0,0 +1,24 @@ +{ + "headers": { + "Authorization": [ + "Bearer [DATABRICKS_TOKEN]" + ], + "User-Agent": [ + "cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/quality-monitor-v2_create-library cmd-exec-id/[UUID] auth/pat" + ] + }, + "method": "GET", + "path": "/api/3.0/operations/operations/test-library-op-456" +} +{ + "headers": { + "Authorization": [ + "Bearer [DATABRICKS_TOKEN]" + ], + "User-Agent": [ + "cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/quality-monitor-v2_create-library cmd-exec-id/[UUID] sdk-feature/long-running auth/pat" + ] + }, + "method": "GET", + "path": "/api/3.0/operations/operations/test-library-op-456" +} diff --git a/acceptance/workspace/quality-monitor-v2/create-library-wait/out.test.toml b/acceptance/workspace/quality-monitor-v2/create-library-wait/out.test.toml new file mode 100644 index 0000000000..e092fd5ed6 --- /dev/null +++ b/acceptance/workspace/quality-monitor-v2/create-library-wait/out.test.toml @@ -0,0 +1,5 @@ +Local = true +Cloud = false + +[EnvMatrix] + DATABRICKS_BUNDLE_ENGINE = ["terraform", "direct-exp"] diff --git a/acceptance/workspace/quality-monitor-v2/create-library-wait/output.txt b/acceptance/workspace/quality-monitor-v2/create-library-wait/output.txt new file mode 100644 index 0000000000..de57de5aa3 --- /dev/null +++ b/acceptance/workspace/quality-monitor-v2/create-library-wait/output.txt @@ -0,0 +1,8 @@ + +>>> [CLI] quality-monitor-v2 create-library operations/test-library-op-456 --wait +{ + "contains_sauce":true, + "created_at":[NUMID], + "leg_count":4, + "name":"test-library-wait" +} diff --git a/acceptance/workspace/quality-monitor-v2/create-library-wait/script b/acceptance/workspace/quality-monitor-v2/create-library-wait/script new file mode 100644 index 0000000000..22eda29933 --- /dev/null +++ b/acceptance/workspace/quality-monitor-v2/create-library-wait/script @@ -0,0 +1 @@ +trace $CLI quality-monitor-v2 create-library operations/test-library-op-456 --wait diff --git a/acceptance/workspace/quality-monitor-v2/create-library-wait/test.toml b/acceptance/workspace/quality-monitor-v2/create-library-wait/test.toml new file mode 100644 index 0000000000..74a1249bd3 --- /dev/null +++ b/acceptance/workspace/quality-monitor-v2/create-library-wait/test.toml @@ -0,0 +1,46 @@ +RecordRequests = true +IncludeRequestHeaders = ["Authorization", "User-Agent"] + +[[Server]] +Pattern = "GET /api/3.0/operations/operations/test-library-op-456" +Response.Body = ''' +{ + "name": "operations/test-library-op-456", + "done": false, + "metadata": { + "created_at": 1234567890, + "library_name": "test-library-wait" + } +} +''' + +[[Server]] +Pattern = "GET /api/3.0/operations/operations/test-library-op-456" +Response.Body = ''' +{ + "name": "operations/test-library-op-456", + "done": true, + "response": { + "name": "test-library-wait", + "leg_count": 4, + "contains_sauce": true, + "created_at": 1234567890 + } +} +''' + +[[Repls]] +Old = "(linux|darwin|windows)" +New = "[OS]" + +[[Repls]] +Old = " upstream/[A-Za-z0-9.-]+" +New = "" + +[[Repls]] +Old = " upstream-version/[A-Za-z0-9.-]+" +New = "" + +[[Repls]] +Old = " cicd/[A-Za-z0-9.-]+" +New = "" diff --git a/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go b/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go index dd6b3be99a..59ee2b9b14 100755 --- a/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go +++ b/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go @@ -3,13 +3,20 @@ package quality_monitor_v2 import ( + "context" + "encoding/json" "fmt" + "time" "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" + "github.com/databricks/databricks-sdk-go" + "github.com/databricks/databricks-sdk-go/retries" + "github.com/databricks/databricks-sdk-go/service/common/lro" "github.com/databricks/databricks-sdk-go/service/qualitymonitorv2" + "github.com/databricks/databricks-sdk-go/useragent" "github.com/spf13/cobra" ) @@ -43,6 +50,59 @@ func New() *cobra.Command { // start create-library command +// pollOperation polls an existing operation until completion, similar to SDK's Wait implementation +func pollOperation(ctx context.Context, w *databricks.WorkspaceClient, operation *qualitymonitorv2.Operation, opts *lro.LroOptions) (*qualitymonitorv2.Library, error) { + timeout := 20 * time.Minute + if opts != nil && opts.Timeout > 0 { + timeout = opts.Timeout + } + + ctx = useragent.InContext(ctx, "sdk-feature", "long-running") + return retries.Poll[qualitymonitorv2.Library](ctx, timeout, func() (*qualitymonitorv2.Library, *retries.Err) { + op, err := w.QualityMonitorV2.GetOperation(ctx, qualitymonitorv2.GetOperationRequest{ + Name: operation.Name, + }) + if err != nil { + return nil, retries.Halt(err) + } + + // Update local operation state + operation = op + + if !op.Done { + return nil, retries.Continues("operation still in progress") + } + + if op.Error != nil { + var errorMsg string + if op.Error.Message != "" { + errorMsg = op.Error.Message + } else { + errorMsg = "unknown error" + } + + if op.Error.ErrorCode != "" { + errorMsg = fmt.Sprintf("[%s] %s", op.Error.ErrorCode, errorMsg) + } + + return nil, retries.Halt(fmt.Errorf("operation failed: %s", errorMsg)) + } + + // Operation completed successfully, unmarshal response + if op.Response == nil { + return nil, retries.Halt(fmt.Errorf("operation completed but no response available")) + } + + var library qualitymonitorv2.Library + err = json.Unmarshal(op.Response, &library) + if err != nil { + return nil, retries.Halt(fmt.Errorf("failed to unmarshal library response: %w", err)) + } + + return &library, nil + }) +} + // Slice with functions to override default command behavior. // Functions can be added from the `init()` function in manually curated files in this directory. var createLibraryOverrides []func( @@ -57,24 +117,42 @@ func newCreateLibrary() *cobra.Command { createLibraryReq.Library = qualitymonitorv2.Library{} var createLibraryJson flags.JsonFlag + var createLibrarySkipWait bool + var createLibraryWait bool + var createLibraryStatus bool + var createLibraryTimeout time.Duration + + cmd.Flags().BoolVar(&createLibrarySkipWait, "no-wait", createLibrarySkipWait, `do not wait to reach DONE state`) + cmd.Flags().BoolVar(&createLibraryWait, "wait", createLibraryWait, `wait for an existing operation to complete`) + cmd.Flags().BoolVar(&createLibraryStatus, "status", createLibraryStatus, `get the status of an existing operation`) + cmd.Flags().DurationVar(&createLibraryTimeout, "timeout", 20*time.Minute, `maximum amount of time to reach DONE state`) + cmd.Flags().Var(&createLibraryJson, "json", `either inline JSON string or @path/to/file.json with request body`) cmd.Flags().BoolVar(&createLibraryReq.Library.ContainsSauce, "contains-sauce", createLibraryReq.Library.ContainsSauce, `Whether the resource contains sauce.`) cmd.Flags().Int64Var(&createLibraryReq.Library.LegCount, "leg-count", createLibraryReq.Library.LegCount, `Count of legs in the resource.`) - cmd.Use = "create-library NAME" + cmd.Use = "create-library NAME [OPERATION_NAME]" cmd.Short = `Create a Library Resource.` cmd.Long = `Create a Library Resource. Arguments: NAME: Name of the Resource. Must contain only: - alphanumeric characters - underscores - hyphens - - Note: The name must be unique within the scope of the resource.` + + Note: The name must be unique within the scope of the resource. + OPERATION_NAME: (Optional) The name of the operation to wait for or check status. + Required when using --wait or --status flags.` cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { + // For --wait or --status, we need exactly 1 arg (operation name) + if cmd.Flags().Changed("wait") || cmd.Flags().Changed("status") { + check := root.ExactArgs(1) + return check(cmd, args) + } + if cmd.Flags().Changed("json") { err := root.ExactArgs(0)(cmd, args) if err != nil { @@ -91,6 +169,39 @@ func newCreateLibrary() *cobra.Command { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + // Handle --status mode: get operation status + if createLibraryStatus { + operationName := args[0] + operation, err := w.QualityMonitorV2.GetOperation(ctx, qualitymonitorv2.GetOperationRequest{ + Name: operationName, + }) + if err != nil { + return err + } + return cmdio.Render(ctx, operation) + } + + // Handle --wait mode: wait for existing operation + if createLibraryWait { + operationName := args[0] + // Get the operation first to construct the wait object + operation, err := w.QualityMonitorV2.GetOperation(ctx, qualitymonitorv2.GetOperationRequest{ + Name: operationName, + }) + if err != nil { + return err + } + + // Manually poll the operation until completion + opts := &lro.LroOptions{Timeout: createLibraryTimeout} + result, err := pollOperation(ctx, w, operation, opts) + if err != nil { + return err + } + return cmdio.Render(ctx, result) + } + + // Handle start operation (--no-wait or default wait) if cmd.Flags().Changed("json") { diags := createLibraryJson.Unmarshal(&createLibraryReq.Library) if diags.HasError() { @@ -107,7 +218,26 @@ func newCreateLibrary() *cobra.Command { createLibraryReq.Library.Name = args[0] } - response, err := w.QualityMonitorV2.CreateLibrary(ctx, createLibraryReq) + wait, err := w.QualityMonitorV2.CreateLibrary(ctx, createLibraryReq) + if err != nil { + return err + } + + // Handle --no-wait: return operation immediately + if createLibrarySkipWait { + // Get the current operation state to return + operation, err := w.QualityMonitorV2.GetOperation(ctx, qualitymonitorv2.GetOperationRequest{ + Name: wait.Name(), + }) + if err != nil { + return err + } + return cmdio.Render(ctx, operation) + } + + // Default: wait for completion + opts := &lro.LroOptions{Timeout: createLibraryTimeout} + response, err := wait.Wait(ctx, opts) if err != nil { return err } From 3be24ba027921228c5861df60dfe5a4453a38701 Mon Sep 17 00:00:00 2001 From: Parth Bansal Date: Thu, 9 Oct 2025 21:31:54 +0000 Subject: [PATCH 5/9] update --- .../quality-monitor-v2/quality-monitor-v2.go | 90 ++++++++++++------- 1 file changed, 56 insertions(+), 34 deletions(-) diff --git a/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go b/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go index 59ee2b9b14..2a89cf2ef4 100755 --- a/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go +++ b/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go @@ -169,8 +169,10 @@ func newCreateLibrary() *cobra.Command { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - // Handle --status mode: get operation status - if createLibraryStatus { + // Determine which mode to execute based on flags + switch { + case createLibraryStatus: + // Status mode: get operation status operationName := args[0] operation, err := w.QualityMonitorV2.GetOperation(ctx, qualitymonitorv2.GetOperationRequest{ Name: operationName, @@ -179,10 +181,9 @@ func newCreateLibrary() *cobra.Command { return err } return cmdio.Render(ctx, operation) - } - // Handle --wait mode: wait for existing operation - if createLibraryWait { + case createLibraryWait: + // Wait mode: wait for existing operation operationName := args[0] // Get the operation first to construct the wait object operation, err := w.QualityMonitorV2.GetOperation(ctx, qualitymonitorv2.GetOperationRequest{ @@ -199,33 +200,31 @@ func newCreateLibrary() *cobra.Command { return err } return cmdio.Render(ctx, result) - } - // Handle start operation (--no-wait or default wait) - if cmd.Flags().Changed("json") { - diags := createLibraryJson.Unmarshal(&createLibraryReq.Library) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) - if err != nil { - return err + case createLibrarySkipWait: + // No-wait mode: start operation and return immediately + if cmd.Flags().Changed("json") { + diags := createLibraryJson.Unmarshal(&createLibraryReq.Library) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } } } - } - if !cmd.Flags().Changed("json") { - createLibraryReq.Library.Name = args[0] - } + if !cmd.Flags().Changed("json") { + createLibraryReq.Library.Name = args[0] + } - wait, err := w.QualityMonitorV2.CreateLibrary(ctx, createLibraryReq) - if err != nil { - return err - } + wait, err := w.QualityMonitorV2.CreateLibrary(ctx, createLibraryReq) + if err != nil { + return err + } - // Handle --no-wait: return operation immediately - if createLibrarySkipWait { - // Get the current operation state to return + // Return operation immediately without waiting operation, err := w.QualityMonitorV2.GetOperation(ctx, qualitymonitorv2.GetOperationRequest{ Name: wait.Name(), }) @@ -233,15 +232,38 @@ func newCreateLibrary() *cobra.Command { return err } return cmdio.Render(ctx, operation) - } - // Default: wait for completion - opts := &lro.LroOptions{Timeout: createLibraryTimeout} - response, err := wait.Wait(ctx, opts) - if err != nil { - return err + default: + // Default mode: start operation and wait for completion + if cmd.Flags().Changed("json") { + diags := createLibraryJson.Unmarshal(&createLibraryReq.Library) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + if !cmd.Flags().Changed("json") { + createLibraryReq.Library.Name = args[0] + } + + wait, err := w.QualityMonitorV2.CreateLibrary(ctx, createLibraryReq) + if err != nil { + return err + } + + // Wait for completion + opts := &lro.LroOptions{Timeout: createLibraryTimeout} + response, err := wait.Wait(ctx, opts) + if err != nil { + return err + } + return cmdio.Render(ctx, response) } - return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. From d01fb66121deb5e3983fb0a1f5ac410aeacff1fe Mon Sep 17 00:00:00 2001 From: Parth Bansal Date: Mon, 13 Oct 2025 14:34:43 +0000 Subject: [PATCH 6/9] update --- .../quality-monitor-v2/quality-monitor-v2.go | 100 ++++-------------- 1 file changed, 23 insertions(+), 77 deletions(-) diff --git a/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go b/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go index 2a89cf2ef4..7e1e88da7e 100755 --- a/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go +++ b/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go @@ -118,13 +118,9 @@ func newCreateLibrary() *cobra.Command { var createLibraryJson flags.JsonFlag var createLibrarySkipWait bool - var createLibraryWait bool - var createLibraryStatus bool var createLibraryTimeout time.Duration cmd.Flags().BoolVar(&createLibrarySkipWait, "no-wait", createLibrarySkipWait, `do not wait to reach DONE state`) - cmd.Flags().BoolVar(&createLibraryWait, "wait", createLibraryWait, `wait for an existing operation to complete`) - cmd.Flags().BoolVar(&createLibraryStatus, "status", createLibraryStatus, `get the status of an existing operation`) cmd.Flags().DurationVar(&createLibraryTimeout, "timeout", 20*time.Minute, `maximum amount of time to reach DONE state`) cmd.Flags().Var(&createLibraryJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -132,27 +128,24 @@ func newCreateLibrary() *cobra.Command { cmd.Flags().BoolVar(&createLibraryReq.Library.ContainsSauce, "contains-sauce", createLibraryReq.Library.ContainsSauce, `Whether the resource contains sauce.`) cmd.Flags().Int64Var(&createLibraryReq.Library.LegCount, "leg-count", createLibraryReq.Library.LegCount, `Count of legs in the resource.`) - cmd.Use = "create-library NAME [OPERATION_NAME]" + cmd.Use = "create-library NAME" cmd.Short = `Create a Library Resource.` cmd.Long = `Create a Library Resource. + + This is a long-running operation. By default, the command waits for the + operation to complete. Use --no-wait to return immediately with the raw + operation details. The operation's 'name' field can then be used to poll for + completion using the get-operation command. Arguments: NAME: Name of the Resource. Must contain only: - alphanumeric characters - underscores - hyphens - Note: The name must be unique within the scope of the resource. - OPERATION_NAME: (Optional) The name of the operation to wait for or check status. - Required when using --wait or --status flags.` + Note: The name must be unique within the scope of the resource.` cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { - // For --wait or --status, we need exactly 1 arg (operation name) - if cmd.Flags().Changed("wait") || cmd.Flags().Changed("status") { - check := root.ExactArgs(1) - return check(cmd, args) - } - if cmd.Flags().Changed("json") { err := root.ExactArgs(0)(cmd, args) if err != nil { @@ -169,56 +162,26 @@ func newCreateLibrary() *cobra.Command { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - // Determine which mode to execute based on flags - switch { - case createLibraryStatus: - // Status mode: get operation status - operationName := args[0] - operation, err := w.QualityMonitorV2.GetOperation(ctx, qualitymonitorv2.GetOperationRequest{ - Name: operationName, - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) - - case createLibraryWait: - // Wait mode: wait for existing operation - operationName := args[0] - // Get the operation first to construct the wait object - operation, err := w.QualityMonitorV2.GetOperation(ctx, qualitymonitorv2.GetOperationRequest{ - Name: operationName, - }) - if err != nil { - return err - } - - // Manually poll the operation until completion - opts := &lro.LroOptions{Timeout: createLibraryTimeout} - result, err := pollOperation(ctx, w, operation, opts) - if err != nil { - return err + // No-wait mode: start operation and return immediately + if cmd.Flags().Changed("json") { + diags := createLibraryJson.Unmarshal(&createLibraryReq.Library) + if diags.HasError() { + return diags.Error() } - return cmdio.Render(ctx, result) - - case createLibrarySkipWait: - // No-wait mode: start operation and return immediately - if cmd.Flags().Changed("json") { - diags := createLibraryJson.Unmarshal(&createLibraryReq.Library) - if diags.HasError() { - return diags.Error() + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err } - if len(diags) > 0 { - err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) - if err != nil { - return err - } - } - } - if !cmd.Flags().Changed("json") { - createLibraryReq.Library.Name = args[0] } + } + if !cmd.Flags().Changed("json") { + createLibraryReq.Library.Name = args[0] + } + // Determine which mode to execute based on flags + switch { + case createLibrarySkipWait: wait, err := w.QualityMonitorV2.CreateLibrary(ctx, createLibraryReq) if err != nil { return err @@ -234,23 +197,6 @@ func newCreateLibrary() *cobra.Command { return cmdio.Render(ctx, operation) default: - // Default mode: start operation and wait for completion - if cmd.Flags().Changed("json") { - diags := createLibraryJson.Unmarshal(&createLibraryReq.Library) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) - if err != nil { - return err - } - } - } - if !cmd.Flags().Changed("json") { - createLibraryReq.Library.Name = args[0] - } - wait, err := w.QualityMonitorV2.CreateLibrary(ctx, createLibraryReq) if err != nil { return err From 8868da49b679a11438090c5062cccf5f232aa9dc Mon Sep 17 00:00:00 2001 From: Parth Bansal Date: Mon, 13 Oct 2025 16:46:16 +0000 Subject: [PATCH 7/9] update --- .../quality-monitor-v2/quality-monitor-v2.go | 63 +------------------ 1 file changed, 2 insertions(+), 61 deletions(-) diff --git a/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go b/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go index 7e1e88da7e..bd1b44460d 100755 --- a/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go +++ b/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go @@ -3,8 +3,6 @@ package quality_monitor_v2 import ( - "context" - "encoding/json" "fmt" "time" @@ -12,11 +10,8 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/retries" "github.com/databricks/databricks-sdk-go/service/common/lro" "github.com/databricks/databricks-sdk-go/service/qualitymonitorv2" - "github.com/databricks/databricks-sdk-go/useragent" "github.com/spf13/cobra" ) @@ -50,59 +45,6 @@ func New() *cobra.Command { // start create-library command -// pollOperation polls an existing operation until completion, similar to SDK's Wait implementation -func pollOperation(ctx context.Context, w *databricks.WorkspaceClient, operation *qualitymonitorv2.Operation, opts *lro.LroOptions) (*qualitymonitorv2.Library, error) { - timeout := 20 * time.Minute - if opts != nil && opts.Timeout > 0 { - timeout = opts.Timeout - } - - ctx = useragent.InContext(ctx, "sdk-feature", "long-running") - return retries.Poll[qualitymonitorv2.Library](ctx, timeout, func() (*qualitymonitorv2.Library, *retries.Err) { - op, err := w.QualityMonitorV2.GetOperation(ctx, qualitymonitorv2.GetOperationRequest{ - Name: operation.Name, - }) - if err != nil { - return nil, retries.Halt(err) - } - - // Update local operation state - operation = op - - if !op.Done { - return nil, retries.Continues("operation still in progress") - } - - if op.Error != nil { - var errorMsg string - if op.Error.Message != "" { - errorMsg = op.Error.Message - } else { - errorMsg = "unknown error" - } - - if op.Error.ErrorCode != "" { - errorMsg = fmt.Sprintf("[%s] %s", op.Error.ErrorCode, errorMsg) - } - - return nil, retries.Halt(fmt.Errorf("operation failed: %s", errorMsg)) - } - - // Operation completed successfully, unmarshal response - if op.Response == nil { - return nil, retries.Halt(fmt.Errorf("operation completed but no response available")) - } - - var library qualitymonitorv2.Library - err = json.Unmarshal(op.Response, &library) - if err != nil { - return nil, retries.Halt(fmt.Errorf("failed to unmarshal library response: %w", err)) - } - - return &library, nil - }) -} - // Slice with functions to override default command behavior. // Functions can be added from the `init()` function in manually curated files in this directory. var createLibraryOverrides []func( @@ -131,7 +73,7 @@ func newCreateLibrary() *cobra.Command { cmd.Use = "create-library NAME" cmd.Short = `Create a Library Resource.` cmd.Long = `Create a Library Resource. - + This is a long-running operation. By default, the command waits for the operation to complete. Use --no-wait to return immediately with the raw operation details. The operation's 'name' field can then be used to poll for @@ -140,7 +82,7 @@ func newCreateLibrary() *cobra.Command { Arguments: NAME: Name of the Resource. Must contain only: - alphanumeric characters - underscores - hyphens - + Note: The name must be unique within the scope of the resource.` cmd.Annotations = make(map[string]string) @@ -162,7 +104,6 @@ func newCreateLibrary() *cobra.Command { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - // No-wait mode: start operation and return immediately if cmd.Flags().Changed("json") { diags := createLibraryJson.Unmarshal(&createLibraryReq.Library) if diags.HasError() { From 17195949b0d1acc3bf9b1954eda49d656e18c9c7 Mon Sep 17 00:00:00 2001 From: Parth Bansal Date: Mon, 13 Oct 2025 19:36:01 +0000 Subject: [PATCH 8/9] update --- cmd/workspace/quality-monitor-v2/quality-monitor-v2.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go b/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go index bd1b44460d..16f7d86efc 100755 --- a/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go +++ b/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go @@ -143,9 +143,14 @@ func newCreateLibrary() *cobra.Command { return err } + // Show spinner while waiting for completion + spinner := cmdio.Spinner(ctx) + spinner <- "Waiting for library creation to complete..." + // Wait for completion opts := &lro.LroOptions{Timeout: createLibraryTimeout} response, err := wait.Wait(ctx, opts) + close(spinner) if err != nil { return err } From 62134f38fcf659d5238e5d249d4206c535796c18 Mon Sep 17 00:00:00 2001 From: Parth Bansal Date: Wed, 15 Oct 2025 12:48:58 +0000 Subject: [PATCH 9/9] update --- cmd/workspace/quality-monitor-v2/quality-monitor-v2.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go b/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go index 16f7d86efc..4fa1817988 100755 --- a/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go +++ b/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go @@ -128,7 +128,7 @@ func newCreateLibrary() *cobra.Command { return err } - // Return operation immediately without waiting + // Return operation immediately without waiting. operation, err := w.QualityMonitorV2.GetOperation(ctx, qualitymonitorv2.GetOperationRequest{ Name: wait.Name(), }) @@ -143,17 +143,17 @@ func newCreateLibrary() *cobra.Command { return err } - // Show spinner while waiting for completion + // Show spinner while waiting for completion. spinner := cmdio.Spinner(ctx) - spinner <- "Waiting for library creation to complete..." + spinner <- "Waiting for create-library to complete..." - // Wait for completion + // Wait for completion. opts := &lro.LroOptions{Timeout: createLibraryTimeout} response, err := wait.Wait(ctx, opts) - close(spinner) if err != nil { return err } + close(spinner) return cmdio.Render(ctx, response) } }