diff --git a/.codegen/_openapi_sha b/.codegen/_openapi_sha index 9834ec958b..3461bf6840 100644 --- a/.codegen/_openapi_sha +++ b/.codegen/_openapi_sha @@ -1 +1 @@ -3ae6f76120079424c8654263eafbc30ec0551854 \ No newline at end of file +6701524136501ef070774942ef5d6e01cfaafb88 \ No newline at end of file diff --git a/.gitattributes b/.gitattributes index 752555fcb0..ef9e69f122 100755 --- a/.gitattributes +++ b/.gitattributes @@ -28,6 +28,7 @@ cmd/account/published-app-integration/published-app-integration.go linguist-gene cmd/account/service-principal-federation-policy/service-principal-federation-policy.go linguist-generated=true cmd/account/service-principal-secrets/service-principal-secrets.go linguist-generated=true cmd/account/service-principals/service-principals.go linguist-generated=true +cmd/account/settings-v2/settings-v2.go linguist-generated=true 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 @@ -44,6 +45,7 @@ cmd/workspace/aibi-dashboard-embedding-approved-domains/aibi-dashboard-embedding cmd/workspace/alerts-legacy/alerts-legacy.go linguist-generated=true cmd/workspace/alerts-v2/alerts-v2.go linguist-generated=true cmd/workspace/alerts/alerts.go linguist-generated=true +cmd/workspace/apps-settings/apps-settings.go linguist-generated=true cmd/workspace/apps/apps.go linguist-generated=true cmd/workspace/artifact-allowlists/artifact-allowlists.go linguist-generated=true cmd/workspace/automatic-cluster-update/automatic-cluster-update.go linguist-generated=true @@ -79,6 +81,7 @@ cmd/workspace/enable-export-notebook/enable-export-notebook.go linguist-generate cmd/workspace/enable-notebook-table-clipboard/enable-notebook-table-clipboard.go linguist-generated=true cmd/workspace/enable-results-downloading/enable-results-downloading.go linguist-generated=true cmd/workspace/enhanced-security-monitoring/enhanced-security-monitoring.go linguist-generated=true +cmd/workspace/entity-tag-assignments/entity-tag-assignments.go linguist-generated=true cmd/workspace/experiments/experiments.go linguist-generated=true cmd/workspace/external-lineage/external-lineage.go linguist-generated=true cmd/workspace/external-locations/external-locations.go linguist-generated=true @@ -135,6 +138,7 @@ cmd/workspace/registered-models/registered-models.go linguist-generated=true cmd/workspace/repos/repos.go linguist-generated=true cmd/workspace/resource-quotas/resource-quotas.go linguist-generated=true cmd/workspace/restrict-workspace-admins/restrict-workspace-admins.go linguist-generated=true +cmd/workspace/rfa/rfa.go linguist-generated=true cmd/workspace/schemas/schemas.go linguist-generated=true cmd/workspace/secrets/secrets.go linguist-generated=true cmd/workspace/service-principal-secrets-proxy/service-principal-secrets-proxy.go linguist-generated=true @@ -147,6 +151,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-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 cmd/workspace/token-management/token-management.go linguist-generated=true @@ -158,4 +163,5 @@ cmd/workspace/volumes/volumes.go linguist-generated=true cmd/workspace/warehouses/warehouses.go linguist-generated=true cmd/workspace/workspace-bindings/workspace-bindings.go linguist-generated=true cmd/workspace/workspace-conf/workspace-conf.go linguist-generated=true +cmd/workspace/workspace-settings-v2/workspace-settings-v2.go linguist-generated=true cmd/workspace/workspace/workspace.go linguist-generated=true diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index a5fc6c061e..c9c865cd46 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -7,6 +7,7 @@ ### Dependency updates * Upgrade TF provider to 1.87.0 ([#3430](https://github.com/databricks/cli/pull/3430)) +* Upgrade Go SDK to 0.81.0 ([#3449](https://github.com/databricks/cli/pull/3449)) ### CLI diff --git a/acceptance/cmd/account/account-help/out.test.toml b/acceptance/cmd/account/account-help/out.test.toml new file mode 100644 index 0000000000..8f3575be7b --- /dev/null +++ b/acceptance/cmd/account/account-help/out.test.toml @@ -0,0 +1,5 @@ +Local = true +Cloud = false + +[EnvMatrix] + DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"] diff --git a/acceptance/cmd/account/account-help/output.txt b/acceptance/cmd/account/account-help/output.txt new file mode 100644 index 0000000000..49b600e26b --- /dev/null +++ b/acceptance/cmd/account/account-help/output.txt @@ -0,0 +1,60 @@ + +>>> [CLI] account --help +Databricks Account Commands + +Usage: + databricks account [command] + +Identity and Access Management + access-control These APIs manage access rules on resources in an account. + groups Groups simplify identity management, making it easier to assign access to Databricks account, data, and other securable objects. + service-principals Identities for use with jobs, automated tools, and systems such as scripts, apps, and CI/CD platforms. + users User identities recognized by Databricks and represented by email addresses. + workspace-assignment The Workspace Permission Assignment API allows you to manage workspace permissions for principals in your account. + +Unity Catalog + metastore-assignments These APIs manage metastore assignments to a workspace. + metastores These APIs manage Unity Catalog metastores for an account. + storage-credentials These APIs manage storage credentials for a particular metastore. + +Settings + ip-access-lists The Accounts IP Access List API enables account admins to configure IP access lists for access to the account console. + network-connectivity These APIs provide configurations for the network connectivity of your workspaces for serverless compute resources. + network-policies These APIs manage network policies for this account. + settings Accounts Settings API allows users to manage settings at the account level. + workspace-network-configuration These APIs allow configuration of network settings for Databricks workspaces by selecting which network policy to associate with the workspace. + +Provisioning + credentials These APIs manage credential configurations for this workspace. + encryption-keys These APIs manage encryption key configurations for this workspace (optional). + networks These APIs manage network configurations for customer-managed VPCs (optional). + private-access These APIs manage private access settings for this account. + storage These APIs manage storage configurations for this workspace. + vpc-endpoints These APIs manage VPC endpoint configurations for this account. + workspaces These APIs manage workspaces for this account. + +Billing + billable-usage This API allows you to download billable usage logs for the specified account and date range. + budget-policy A service serves REST API about Budget policies. + budgets These APIs manage budget configurations for this account. + log-delivery These APIs manage log delivery configurations for this account. + usage-dashboards These APIs manage usage dashboards for this account. + +OAuth + custom-app-integration These APIs enable administrators to manage custom OAuth app integrations, which is required for adding/using Custom OAuth App Integration like Tableau Cloud for Databricks in AWS cloud. + federation-policy These APIs manage account federation policies. + o-auth-published-apps These APIs enable administrators to view all the available published OAuth applications in Databricks. + published-app-integration These APIs enable administrators to manage published OAuth app integrations, which is required for adding/using Published OAuth App Integration like Tableau Desktop for Databricks in AWS cloud. + service-principal-federation-policy These APIs manage service principal federation policies. + service-principal-secrets These APIs enable administrators to manage service principal secrets. + +Flags: + -h, --help help for account + +Global Flags: + --debug enable debug logging + -o, --output type output type: text or json (default text) + -p, --profile string ~/.databrickscfg profile + -t, --target string bundle target to use (if applicable) + +Use "databricks account [command] --help" for more information about a command. diff --git a/acceptance/cmd/account/account-help/script b/acceptance/cmd/account/account-help/script new file mode 100644 index 0000000000..697cfcaa25 --- /dev/null +++ b/acceptance/cmd/account/account-help/script @@ -0,0 +1 @@ +trace $CLI account --help diff --git a/acceptance/help/output.txt b/acceptance/help/output.txt index ecbd017ec5..d6ed2b16d7 100644 --- a/acceptance/help/output.txt +++ b/acceptance/help/output.txt @@ -57,6 +57,7 @@ Unity Catalog catalogs A catalog is the first layer of Unity Catalog’s three-level namespace. connections Connections allow for creating a connection to an external data source. credentials A credential represents an authentication and authorization mechanism for accessing services on your cloud tenant. + entity-tag-assignments Tags are attributes that include keys and optional values that you can use to organize and categorize entities in Unity Catalog. external-lineage External Lineage APIs enable defining and managing lineage relationships between Databricks objects and external systems. external-locations An external location is an object that combines a cloud storage path with a storage credential that authorizes access to the cloud storage path. external-metadata External Metadata objects enable customers to register and manage metadata about external systems within Unity Catalog. @@ -65,9 +66,11 @@ Unity Catalog metastores A metastore is the top-level container of objects in Unity Catalog. model-versions Databricks provides a hosted version of MLflow Model Registry in Unity Catalog. online-tables Online tables provide lower latency and higher QPS access to data from Delta tables. + policies Attribute-Based Access Control (ABAC) provides high leverage governance for enforcing compliance policies in Unity Catalog. quality-monitors A monitor computes and monitors data or model quality metrics for a table over time. registered-models Databricks provides a hosted version of MLflow Model Registry in Unity Catalog. resource-quotas Unity Catalog enforces resource quotas on all securable objects, which limits the number of resources that can be created. + rfa Request for Access enables customers to request access to and manage access request destinations for Unity Catalog securables. schemas A schema (also called a database) is the second layer of Unity Catalog’s three-level namespace. storage-credentials A storage credential represents an authentication and authorization mechanism for accessing data stored on your cloud tenant. system-schemas A system schema is a schema that lives within the system catalog. diff --git a/acceptance/selftest/skip/out.test.toml b/acceptance/selftest/skip/out.test.toml new file mode 100644 index 0000000000..8f3575be7b --- /dev/null +++ b/acceptance/selftest/skip/out.test.toml @@ -0,0 +1,5 @@ +Local = true +Cloud = false + +[EnvMatrix] + DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"] diff --git a/bundle/internal/schema/annotations_openapi.yml b/bundle/internal/schema/annotations_openapi.yml index 96746b2595..79cfb8fc06 100644 --- a/bundle/internal/schema/annotations_openapi.yml +++ b/bundle/internal/schema/annotations_openapi.yml @@ -246,6 +246,18 @@ github.com/databricks/cli/bundle/config/resources.Cluster: "workload_type": "description": |- Cluster Attributes showing for clusters workload types. +github.com/databricks/cli/bundle/config/resources.DatabaseCatalog: + "create_database_if_not_exists": {} + "database_instance_name": + "description": |- + The name of the DatabaseInstance housing the database. + "database_name": + "description": |- + The name of the database (in a instance) associated with the catalog. + "name": + "description": |- + The name of the catalog in UC. + "uid": {} github.com/databricks/cli/bundle/config/resources.DatabaseInstance: "_": "description": |- @@ -423,7 +435,7 @@ github.com/databricks/cli/bundle/config/resources.Job: "description": |- The id of the user specified usage policy to use for this job. If not specified, a default usage policy may be applied when creating or modifying the job. - See `effective_budget_policy_id` for the budget policy used by this workload. + See `effective_usage_policy_id` for the usage policy used by this workload. "x-databricks-preview": |- PRIVATE "webhook_notifications": @@ -3604,6 +3616,9 @@ github.com/databricks/databricks-sdk-go/service/serving.AiGatewayRateLimit: "renewal_period": "description": |- Renewal period field for a rate limit. Currently, only 'minute' is supported. + "tokens": + "description": |- + Used to specify how many tokens are allowed for a key within the renewal_period. github.com/databricks/databricks-sdk-go/service/serving.AiGatewayRateLimitKey: "_": "enum": diff --git a/bundle/internal/validation/generated/required_fields.go b/bundle/internal/validation/generated/required_fields.go index a2fa05241e..542e64ae44 100644 --- a/bundle/internal/validation/generated/required_fields.go +++ b/bundle/internal/validation/generated/required_fields.go @@ -40,6 +40,8 @@ var RequiredFields = map[string][]string{ "resources.dashboards.*.permissions[*]": {"level"}, + "resources.database_catalogs.*": {"database_instance_name", "database_name", "name"}, + "resources.database_instances.*": {"name"}, "resources.database_instances.*.permissions[*]": {"level"}, diff --git a/bundle/schema/jsonschema.json b/bundle/schema/jsonschema.json index 5f13667d70..c0aec94eb8 100644 --- a/bundle/schema/jsonschema.json +++ b/bundle/schema/jsonschema.json @@ -779,7 +779,7 @@ "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/jobs.TriggerSettings" }, "usage_policy_id": { - "description": "The id of the user specified usage policy to use for this job.\nIf not specified, a default usage policy may be applied when creating or modifying the job.\nSee `effective_budget_policy_id` for the budget policy used by this workload.", + "description": "The id of the user specified usage policy to use for this job.\nIf not specified, a default usage policy may be applied when creating or modifying the job.\nSee `effective_usage_policy_id` for the usage policy used by this workload.", "$ref": "#/$defs/string", "x-databricks-preview": "PRIVATE", "doNotSuggest": true @@ -7329,6 +7329,10 @@ "renewal_period": { "description": "Renewal period field for a rate limit. Currently, only 'minute' is supported.", "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/serving.AiGatewayRateLimitRenewalPeriod" + }, + "tokens": { + "description": "Used to specify how many tokens are allowed for a key within the renewal_period.", + "$ref": "#/$defs/int64" } }, "additionalProperties": false, diff --git a/cmd/account/cmd.go b/cmd/account/cmd.go index cd70e73cf8..bdbab94761 100644 --- a/cmd/account/cmd.go +++ b/cmd/account/cmd.go @@ -3,6 +3,7 @@ package account import ( + "github.com/databricks/cli/libs/cmdgroup" "github.com/spf13/cobra" account_access_control "github.com/databricks/cli/cmd/account/access-control" @@ -28,6 +29,7 @@ import ( service_principal_secrets "github.com/databricks/cli/cmd/account/service-principal-secrets" account_service_principals "github.com/databricks/cli/cmd/account/service-principals" account_settings "github.com/databricks/cli/cmd/account/settings" + account_settings_v2 "github.com/databricks/cli/cmd/account/settings-v2" 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" @@ -66,6 +68,7 @@ func New() *cobra.Command { cmd.AddCommand(service_principal_secrets.New()) cmd.AddCommand(account_service_principals.New()) cmd.AddCommand(account_settings.New()) + cmd.AddCommand(account_settings_v2.New()) cmd.AddCommand(storage.New()) cmd.AddCommand(account_storage_credentials.New()) cmd.AddCommand(usage_dashboards.New()) @@ -76,10 +79,12 @@ func New() *cobra.Command { cmd.AddCommand(workspaces.New()) cmd.AddCommand(budgets.New()) - // Register all groups with the parent command. - groups := Groups() - for i := range groups { - cmd.AddGroup(&groups[i]) + // Add account command groups, filtering out empty groups or groups with only hidden commands. + allGroups := Groups() + allCommands := cmd.Commands() + filteredGroups := cmdgroup.FilterGroups(allGroups, allCommands) + for i := range filteredGroups { + cmd.AddGroup(&filteredGroups[i]) } return cmd diff --git a/cmd/account/groups.go b/cmd/account/groups.go index 10a795b037..841c7736ad 100644 --- a/cmd/account/groups.go +++ b/cmd/account/groups.go @@ -18,6 +18,10 @@ func Groups() []cobra.Group { ID: "settings", Title: "Settings", }, + { + ID: "settingsv2", + Title: "Settings (v2)", + }, { ID: "provisioning", Title: "Provisioning", diff --git a/cmd/account/settings-v2/settings-v2.go b/cmd/account/settings-v2/settings-v2.go new file mode 100755 index 0000000000..2f2a5fe307 --- /dev/null +++ b/cmd/account/settings-v2/settings-v2.go @@ -0,0 +1,244 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package settings_v2 + +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/settingsv2" + "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: "settings-v2", + Short: `APIs to manage account level settings.`, + Long: `APIs to manage account level settings`, + GroupID: "settingsv2", + Annotations: map[string]string{ + "package": "settingsv2", + }, + + // This service is being previewed; hide from help output. + Hidden: true, + RunE: root.ReportUnknownSubcommand, + } + + // Add methods + cmd.AddCommand(newGetPublicAccountSetting()) + cmd.AddCommand(newListAccountSettingsMetadata()) + cmd.AddCommand(newPatchPublicAccountSetting()) + + // Apply optional overrides to this command. + for _, fn := range cmdOverrides { + fn(cmd) + } + + return cmd +} + +// start get-public-account-setting 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 getPublicAccountSettingOverrides []func( + *cobra.Command, + *settingsv2.GetPublicAccountSettingRequest, +) + +func newGetPublicAccountSetting() *cobra.Command { + cmd := &cobra.Command{} + + var getPublicAccountSettingReq settingsv2.GetPublicAccountSettingRequest + + cmd.Use = "get-public-account-setting NAME" + cmd.Short = `Get an account setting.` + cmd.Long = `Get an account setting. + + Get a setting value at account level` + + 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) + + getPublicAccountSettingReq.Name = args[0] + + response, err := a.SettingsV2.GetPublicAccountSetting(ctx, getPublicAccountSettingReq) + 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 getPublicAccountSettingOverrides { + fn(cmd, &getPublicAccountSettingReq) + } + + return cmd +} + +// start list-account-settings-metadata 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 listAccountSettingsMetadataOverrides []func( + *cobra.Command, + *settingsv2.ListAccountSettingsMetadataRequest, +) + +func newListAccountSettingsMetadata() *cobra.Command { + cmd := &cobra.Command{} + + var listAccountSettingsMetadataReq settingsv2.ListAccountSettingsMetadataRequest + + cmd.Flags().IntVar(&listAccountSettingsMetadataReq.PageSize, "page-size", listAccountSettingsMetadataReq.PageSize, `The maximum number of settings to return.`) + cmd.Flags().StringVar(&listAccountSettingsMetadataReq.PageToken, "page-token", listAccountSettingsMetadataReq.PageToken, `A page token, received from a previous ListAccountSettingsMetadataRequest call.`) + + cmd.Use = "list-account-settings-metadata" + cmd.Short = `List valid setting keys and their metadata.` + cmd.Long = `List valid setting keys and their metadata. + + List valid setting keys and metadata. These settings are available to + referenced via [GET + /api/2.1/settings/{name}](#~1api~1account~1settingsv2~1getpublicaccountsetting) + and [PATCH + /api/2.1/settings/{name}](#~1api~1account~1settingsv2~patchpublicaccountsetting) + APIs` + + 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.SettingsV2.ListAccountSettingsMetadata(ctx, listAccountSettingsMetadataReq) + 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 listAccountSettingsMetadataOverrides { + fn(cmd, &listAccountSettingsMetadataReq) + } + + return cmd +} + +// start patch-public-account-setting 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 patchPublicAccountSettingOverrides []func( + *cobra.Command, + *settingsv2.PatchPublicAccountSettingRequest, +) + +func newPatchPublicAccountSetting() *cobra.Command { + cmd := &cobra.Command{} + + var patchPublicAccountSettingReq settingsv2.PatchPublicAccountSettingRequest + patchPublicAccountSettingReq.Setting = settingsv2.Setting{} + var patchPublicAccountSettingJson flags.JsonFlag + + cmd.Flags().Var(&patchPublicAccountSettingJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + // TODO: complex arg: aibi_dashboard_embedding_access_policy + // TODO: complex arg: aibi_dashboard_embedding_approved_domains + // TODO: complex arg: automatic_cluster_update_workspace + // TODO: complex arg: boolean_val + // TODO: complex arg: default_data_security_mode + // TODO: complex arg: effective_aibi_dashboard_embedding_access_policy + // TODO: complex arg: effective_aibi_dashboard_embedding_approved_domains + // TODO: complex arg: effective_automatic_cluster_update_workspace + // TODO: complex arg: effective_boolean_val + // TODO: complex arg: effective_default_data_security_mode + // TODO: complex arg: effective_integer_val + // TODO: complex arg: effective_personal_compute + // TODO: complex arg: effective_restrict_workspace_admins + // TODO: complex arg: effective_string_val + // TODO: complex arg: integer_val + cmd.Flags().StringVar(&patchPublicAccountSettingReq.Setting.Name, "name", patchPublicAccountSettingReq.Setting.Name, `Name of the setting.`) + // TODO: complex arg: personal_compute + // TODO: complex arg: restrict_workspace_admins + // TODO: complex arg: string_val + + cmd.Use = "patch-public-account-setting NAME" + cmd.Short = `Update an account setting.` + cmd.Long = `Update an account setting. + + Patch a setting value at account level` + + 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 := patchPublicAccountSettingJson.Unmarshal(&patchPublicAccountSettingReq.Setting) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + patchPublicAccountSettingReq.Name = args[0] + + response, err := a.SettingsV2.PatchPublicAccountSetting(ctx, patchPublicAccountSettingReq) + 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 patchPublicAccountSettingOverrides { + fn(cmd, &patchPublicAccountSettingReq) + } + + return cmd +} + +// end service AccountSettingsV2 diff --git a/cmd/cmd.go b/cmd/cmd.go index ef90ccca6a..1994d96801 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -19,6 +19,7 @@ import ( "github.com/databricks/cli/cmd/sync" "github.com/databricks/cli/cmd/version" "github.com/databricks/cli/cmd/workspace" + "github.com/databricks/cli/libs/cmdgroup" "github.com/spf13/cobra" ) @@ -27,41 +28,6 @@ const ( permissionsGroup = "permissions" ) -// filterGroups returns command groups that have at least one available (non-hidden) command. -// Empty groups or groups with only hidden commands are filtered out from the help output. -// Commands that belong to filtered groups will have their GroupID cleared. -func filterGroups(groups []cobra.Group, allCommands []*cobra.Command) []cobra.Group { - var filteredGroups []cobra.Group - - // Create a map to track which groups have available commands - groupHasAvailableCommands := make(map[string]bool) - - // Check each command to see if it belongs to a group and is available - for _, cmd := range allCommands { - if cmd.GroupID != "" && cmd.IsAvailableCommand() { - groupHasAvailableCommands[cmd.GroupID] = true - } - } - - // Collect groups that have available commands - validGroupIDs := make(map[string]bool) - for _, group := range groups { - if groupHasAvailableCommands[group.ID] { - filteredGroups = append(filteredGroups, group) - validGroupIDs[group.ID] = true - } - } - - // Clear GroupID for commands that belong to filtered groups - for _, cmd := range allCommands { - if cmd.GroupID != "" && !validGroupIDs[cmd.GroupID] { - cmd.GroupID = "" - } - } - - return filteredGroups -} - func New(ctx context.Context) *cobra.Command { cli := root.New(ctx) @@ -115,7 +81,7 @@ func New(ctx context.Context) *cobra.Command { // Add workspace command groups, filtering out empty groups or groups with only hidden commands. allGroups := workspace.Groups() allCommands := cli.Commands() - filteredGroups := filterGroups(allGroups, allCommands) + filteredGroups := cmdgroup.FilterGroups(allGroups, allCommands) for i := range filteredGroups { cli.AddGroup(&filteredGroups[i]) } diff --git a/cmd/workspace/agent-bricks/agent-bricks.go b/cmd/workspace/agent-bricks/agent-bricks.go index 06e61d7434..3301dc8b75 100755 --- a/cmd/workspace/agent-bricks/agent-bricks.go +++ b/cmd/workspace/agent-bricks/agent-bricks.go @@ -117,7 +117,7 @@ func newCreateCustomLlm() *cobra.Command { cmd.Flags().Var(&createCustomLlmJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createCustomLlmReq.AgentArtifactPath, "agent-artifact-path", createCustomLlmReq.AgentArtifactPath, `Optional: UC path for agent artifacts.`) + cmd.Flags().StringVar(&createCustomLlmReq.AgentArtifactPath, "agent-artifact-path", createCustomLlmReq.AgentArtifactPath, `This will soon be deprecated!! Optional: UC path for agent artifacts.`) // TODO: array: datasets // TODO: array: guidelines diff --git a/cmd/workspace/alerts-v2/alerts-v2.go b/cmd/workspace/alerts-v2/alerts-v2.go index 2447dc32dd..87a0d0f70c 100755 --- a/cmd/workspace/alerts-v2/alerts-v2.go +++ b/cmd/workspace/alerts-v2/alerts-v2.go @@ -65,9 +65,11 @@ func newCreateAlert() *cobra.Command { cmd.Flags().StringVar(&createAlertReq.Alert.CustomDescription, "custom-description", createAlertReq.Alert.CustomDescription, `Custom description for the alert.`) cmd.Flags().StringVar(&createAlertReq.Alert.CustomSummary, "custom-summary", createAlertReq.Alert.CustomSummary, `Custom summary for the alert.`) cmd.Flags().StringVar(&createAlertReq.Alert.DisplayName, "display-name", createAlertReq.Alert.DisplayName, `The display name of the alert.`) + // TODO: complex arg: effective_run_as // TODO: complex arg: evaluation cmd.Flags().StringVar(&createAlertReq.Alert.ParentPath, "parent-path", createAlertReq.Alert.ParentPath, `The workspace path of the folder containing the alert.`) cmd.Flags().StringVar(&createAlertReq.Alert.QueryText, "query-text", createAlertReq.Alert.QueryText, `Text of the query to be run.`) + // TODO: complex arg: run_as cmd.Flags().StringVar(&createAlertReq.Alert.RunAsUserName, "run-as-user-name", createAlertReq.Alert.RunAsUserName, `The run as username or application ID of service principal.`) // TODO: complex arg: schedule cmd.Flags().StringVar(&createAlertReq.Alert.WarehouseId, "warehouse-id", createAlertReq.Alert.WarehouseId, `ID of the SQL warehouse attached to the alert.`) @@ -326,9 +328,11 @@ func newUpdateAlert() *cobra.Command { cmd.Flags().StringVar(&updateAlertReq.Alert.CustomDescription, "custom-description", updateAlertReq.Alert.CustomDescription, `Custom description for the alert.`) cmd.Flags().StringVar(&updateAlertReq.Alert.CustomSummary, "custom-summary", updateAlertReq.Alert.CustomSummary, `Custom summary for the alert.`) cmd.Flags().StringVar(&updateAlertReq.Alert.DisplayName, "display-name", updateAlertReq.Alert.DisplayName, `The display name of the alert.`) + // TODO: complex arg: effective_run_as // TODO: complex arg: evaluation cmd.Flags().StringVar(&updateAlertReq.Alert.ParentPath, "parent-path", updateAlertReq.Alert.ParentPath, `The workspace path of the folder containing the alert.`) cmd.Flags().StringVar(&updateAlertReq.Alert.QueryText, "query-text", updateAlertReq.Alert.QueryText, `Text of the query to be run.`) + // TODO: complex arg: run_as cmd.Flags().StringVar(&updateAlertReq.Alert.RunAsUserName, "run-as-user-name", updateAlertReq.Alert.RunAsUserName, `The run as username or application ID of service principal.`) // TODO: complex arg: schedule cmd.Flags().StringVar(&updateAlertReq.Alert.WarehouseId, "warehouse-id", updateAlertReq.Alert.WarehouseId, `ID of the SQL warehouse attached to the alert.`) diff --git a/cmd/workspace/apps-settings/apps-settings.go b/cmd/workspace/apps-settings/apps-settings.go new file mode 100755 index 0000000000..94cbd13299 --- /dev/null +++ b/cmd/workspace/apps-settings/apps-settings.go @@ -0,0 +1,423 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package apps_settings + +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/apps" + "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: "apps-settings", + Short: `Apps Settings manage the settings for the Apps service on a customer's Databricks instance.`, + Long: `Apps Settings manage the settings for the Apps service on a customer's + Databricks instance.`, + GroupID: "apps", + Annotations: map[string]string{ + "package": "apps", + }, + + // This service is being previewed; hide from help output. + Hidden: true, + RunE: root.ReportUnknownSubcommand, + } + + // Add methods + cmd.AddCommand(newCreateCustomTemplate()) + cmd.AddCommand(newDeleteCustomTemplate()) + cmd.AddCommand(newGetCustomTemplate()) + cmd.AddCommand(newListCustomTemplates()) + cmd.AddCommand(newUpdateCustomTemplate()) + + // Apply optional overrides to this command. + for _, fn := range cmdOverrides { + fn(cmd) + } + + return cmd +} + +// start create-custom-template 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 createCustomTemplateOverrides []func( + *cobra.Command, + *apps.CreateCustomTemplateRequest, +) + +func newCreateCustomTemplate() *cobra.Command { + cmd := &cobra.Command{} + + var createCustomTemplateReq apps.CreateCustomTemplateRequest + createCustomTemplateReq.Template = apps.CustomTemplate{} + var createCustomTemplateJson flags.JsonFlag + + cmd.Flags().Var(&createCustomTemplateJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&createCustomTemplateReq.Template.Description, "description", createCustomTemplateReq.Template.Description, `The description of the template.`) + + cmd.Use = "create-custom-template NAME GIT_REPO PATH MANIFEST GIT_PROVIDER" + cmd.Short = `Create a template.` + cmd.Long = `Create a template. + + Creates a custom template. + + Arguments: + NAME: The name of the template. It must contain only alphanumeric characters, + hyphens, underscores, and whitespaces. It must be unique within the + workspace. + GIT_REPO: The Git repository URL that the template resides in. + PATH: The path to the template within the Git repository. + MANIFEST: The manifest of the template. It defines fields and default values when + installing the template. + GIT_PROVIDER: The Git provider of the template.` + + 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', 'git_repo', 'path', 'manifest', 'git_provider' 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 := createCustomTemplateJson.Unmarshal(&createCustomTemplateReq.Template) + 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") { + createCustomTemplateReq.Template.Name = args[0] + } + if !cmd.Flags().Changed("json") { + createCustomTemplateReq.Template.GitRepo = args[1] + } + if !cmd.Flags().Changed("json") { + createCustomTemplateReq.Template.Path = args[2] + } + if !cmd.Flags().Changed("json") { + _, err = fmt.Sscan(args[3], &createCustomTemplateReq.Template.Manifest) + if err != nil { + return fmt.Errorf("invalid MANIFEST: %s", args[3]) + } + } + if !cmd.Flags().Changed("json") { + createCustomTemplateReq.Template.GitProvider = args[4] + } + + response, err := w.AppsSettings.CreateCustomTemplate(ctx, createCustomTemplateReq) + 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 createCustomTemplateOverrides { + fn(cmd, &createCustomTemplateReq) + } + + return cmd +} + +// start delete-custom-template 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 deleteCustomTemplateOverrides []func( + *cobra.Command, + *apps.DeleteCustomTemplateRequest, +) + +func newDeleteCustomTemplate() *cobra.Command { + cmd := &cobra.Command{} + + var deleteCustomTemplateReq apps.DeleteCustomTemplateRequest + + cmd.Use = "delete-custom-template NAME" + cmd.Short = `Delete a template.` + cmd.Long = `Delete a template. + + Deletes the custom template with the specified name. + + Arguments: + NAME: The name of the custom template.` + + 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) + + deleteCustomTemplateReq.Name = args[0] + + response, err := w.AppsSettings.DeleteCustomTemplate(ctx, deleteCustomTemplateReq) + 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 deleteCustomTemplateOverrides { + fn(cmd, &deleteCustomTemplateReq) + } + + return cmd +} + +// start get-custom-template 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 getCustomTemplateOverrides []func( + *cobra.Command, + *apps.GetCustomTemplateRequest, +) + +func newGetCustomTemplate() *cobra.Command { + cmd := &cobra.Command{} + + var getCustomTemplateReq apps.GetCustomTemplateRequest + + cmd.Use = "get-custom-template NAME" + cmd.Short = `Get a template.` + cmd.Long = `Get a template. + + Gets the custom template with the specified name. + + Arguments: + NAME: The name of the custom template.` + + 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) + + getCustomTemplateReq.Name = args[0] + + response, err := w.AppsSettings.GetCustomTemplate(ctx, getCustomTemplateReq) + 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 getCustomTemplateOverrides { + fn(cmd, &getCustomTemplateReq) + } + + return cmd +} + +// start list-custom-templates 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 listCustomTemplatesOverrides []func( + *cobra.Command, + *apps.ListCustomTemplatesRequest, +) + +func newListCustomTemplates() *cobra.Command { + cmd := &cobra.Command{} + + var listCustomTemplatesReq apps.ListCustomTemplatesRequest + + cmd.Flags().IntVar(&listCustomTemplatesReq.PageSize, "page-size", listCustomTemplatesReq.PageSize, `Upper bound for items returned.`) + cmd.Flags().StringVar(&listCustomTemplatesReq.PageToken, "page-token", listCustomTemplatesReq.PageToken, `Pagination token to go to the next page of custom templates.`) + + cmd.Use = "list-custom-templates" + cmd.Short = `List templates.` + cmd.Long = `List templates. + + Lists all custom templates in the workspace.` + + 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.AppsSettings.ListCustomTemplates(ctx, listCustomTemplatesReq) + 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 listCustomTemplatesOverrides { + fn(cmd, &listCustomTemplatesReq) + } + + return cmd +} + +// start update-custom-template 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 updateCustomTemplateOverrides []func( + *cobra.Command, + *apps.UpdateCustomTemplateRequest, +) + +func newUpdateCustomTemplate() *cobra.Command { + cmd := &cobra.Command{} + + var updateCustomTemplateReq apps.UpdateCustomTemplateRequest + updateCustomTemplateReq.Template = apps.CustomTemplate{} + var updateCustomTemplateJson flags.JsonFlag + + cmd.Flags().Var(&updateCustomTemplateJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&updateCustomTemplateReq.Template.Description, "description", updateCustomTemplateReq.Template.Description, `The description of the template.`) + + cmd.Use = "update-custom-template NAME GIT_REPO PATH MANIFEST GIT_PROVIDER" + cmd.Short = `Update a template.` + cmd.Long = `Update a template. + + Updates the custom template with the specified name. Note that the template + name cannot be updated. + + Arguments: + NAME: The name of the template. It must contain only alphanumeric characters, + hyphens, underscores, and whitespaces. It must be unique within the + workspace. + GIT_REPO: The Git repository URL that the template resides in. + PATH: The path to the template within the Git repository. + MANIFEST: The manifest of the template. It defines fields and default values when + installing the template. + GIT_PROVIDER: The Git provider of the template.` + + 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 NAME as positional arguments. Provide 'name', 'git_repo', 'path', 'manifest', 'git_provider' 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 := updateCustomTemplateJson.Unmarshal(&updateCustomTemplateReq.Template) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + updateCustomTemplateReq.Name = args[0] + if !cmd.Flags().Changed("json") { + updateCustomTemplateReq.Template.GitRepo = args[1] + } + if !cmd.Flags().Changed("json") { + updateCustomTemplateReq.Template.Path = args[2] + } + if !cmd.Flags().Changed("json") { + _, err = fmt.Sscan(args[3], &updateCustomTemplateReq.Template.Manifest) + if err != nil { + return fmt.Errorf("invalid MANIFEST: %s", args[3]) + } + } + if !cmd.Flags().Changed("json") { + updateCustomTemplateReq.Template.GitProvider = args[4] + } + + response, err := w.AppsSettings.UpdateCustomTemplate(ctx, updateCustomTemplateReq) + 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 updateCustomTemplateOverrides { + fn(cmd, &updateCustomTemplateReq) + } + + return cmd +} + +// end service AppsSettings diff --git a/cmd/workspace/clean-rooms/clean-rooms.go b/cmd/workspace/clean-rooms/clean-rooms.go index 7b7dd6bdb8..4b94810aa7 100755 --- a/cmd/workspace/clean-rooms/clean-rooms.go +++ b/cmd/workspace/clean-rooms/clean-rooms.go @@ -75,7 +75,7 @@ func newCreate() *cobra.Command { cmd.Flags().StringVar(&createReq.CleanRoom.Comment, "comment", createReq.CleanRoom.Comment, ``) cmd.Flags().StringVar(&createReq.CleanRoom.Name, "name", createReq.CleanRoom.Name, `The name of the clean room.`) // TODO: complex arg: output_catalog - cmd.Flags().StringVar(&createReq.CleanRoom.Owner, "owner", createReq.CleanRoom.Owner, `This is Databricks username of the owner of the local clean room securable for permission management.`) + cmd.Flags().StringVar(&createReq.CleanRoom.Owner, "owner", createReq.CleanRoom.Owner, `This is the Databricks username of the owner of the local clean room securable for permission management.`) // TODO: complex arg: remote_detailed_info cmd.Use = "create" diff --git a/cmd/workspace/cmd.go b/cmd/workspace/cmd.go index e0f0a5f391..5cbc87dccc 100755 --- a/cmd/workspace/cmd.go +++ b/cmd/workspace/cmd.go @@ -9,6 +9,7 @@ import ( alerts_legacy "github.com/databricks/cli/cmd/workspace/alerts-legacy" alerts_v2 "github.com/databricks/cli/cmd/workspace/alerts-v2" apps "github.com/databricks/cli/cmd/workspace/apps" + apps_settings "github.com/databricks/cli/cmd/workspace/apps-settings" artifact_allowlists "github.com/databricks/cli/cmd/workspace/artifact-allowlists" catalogs "github.com/databricks/cli/cmd/workspace/catalogs" clean_room_asset_revisions "github.com/databricks/cli/cmd/workspace/clean-room-asset-revisions" @@ -31,6 +32,7 @@ import ( dashboards "github.com/databricks/cli/cmd/workspace/dashboards" data_sources "github.com/databricks/cli/cmd/workspace/data-sources" database "github.com/databricks/cli/cmd/workspace/database" + 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" external_locations "github.com/databricks/cli/cmd/workspace/external-locations" @@ -85,6 +87,7 @@ import ( registered_models "github.com/databricks/cli/cmd/workspace/registered-models" repos "github.com/databricks/cli/cmd/workspace/repos" resource_quotas "github.com/databricks/cli/cmd/workspace/resource-quotas" + rfa "github.com/databricks/cli/cmd/workspace/rfa" schemas "github.com/databricks/cli/cmd/workspace/schemas" secrets "github.com/databricks/cli/cmd/workspace/secrets" service_principal_secrets_proxy "github.com/databricks/cli/cmd/workspace/service-principal-secrets-proxy" @@ -96,6 +99,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_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" token_management "github.com/databricks/cli/cmd/workspace/token-management" @@ -108,6 +112,7 @@ import ( workspace "github.com/databricks/cli/cmd/workspace/workspace" workspace_bindings "github.com/databricks/cli/cmd/workspace/workspace-bindings" workspace_conf "github.com/databricks/cli/cmd/workspace/workspace-conf" + workspace_settings_v2 "github.com/databricks/cli/cmd/workspace/workspace-settings-v2" "github.com/spf13/cobra" ) @@ -120,6 +125,7 @@ func All() []*cobra.Command { out = append(out, alerts_legacy.New()) out = append(out, alerts_v2.New()) out = append(out, apps.New()) + out = append(out, apps_settings.New()) out = append(out, artifact_allowlists.New()) out = append(out, catalogs.New()) out = append(out, clean_room_asset_revisions.New()) @@ -142,6 +148,7 @@ func All() []*cobra.Command { out = append(out, dashboards.New()) out = append(out, data_sources.New()) out = append(out, database.New()) + out = append(out, entity_tag_assignments.New()) out = append(out, experiments.New()) out = append(out, external_lineage.New()) out = append(out, external_locations.New()) @@ -195,6 +202,7 @@ func All() []*cobra.Command { out = append(out, registered_models.New()) out = append(out, repos.New()) out = append(out, resource_quotas.New()) + out = append(out, rfa.New()) out = append(out, schemas.New()) out = append(out, secrets.New()) out = append(out, service_principal_secrets_proxy.New()) @@ -206,6 +214,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_policies.New()) out = append(out, temporary_path_credentials.New()) out = append(out, temporary_table_credentials.New()) out = append(out, token_management.New()) @@ -218,6 +227,7 @@ 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()) return out diff --git a/cmd/workspace/connections/connections.go b/cmd/workspace/connections/connections.go index 761f278c29..bae12cd8ef 100755 --- a/cmd/workspace/connections/connections.go +++ b/cmd/workspace/connections/connections.go @@ -72,7 +72,6 @@ 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.`) @@ -331,7 +330,6 @@ 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/entity-tag-assignments/entity-tag-assignments.go b/cmd/workspace/entity-tag-assignments/entity-tag-assignments.go new file mode 100755 index 0000000000..392f9728d5 --- /dev/null +++ b/cmd/workspace/entity-tag-assignments/entity-tag-assignments.go @@ -0,0 +1,445 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package entity_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/catalog" + "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: "entity-tag-assignments", + Short: `Tags are attributes that include keys and optional values that you can use to organize and categorize entities in Unity Catalog.`, + Long: `Tags are attributes that include keys and optional values that you can use to + organize and categorize entities in Unity Catalog. Entity tagging is currently + supported on catalogs, schemas, tables (including views), columns, volumes. + With these APIs, users can create, update, delete, and list tag assignments + across Unity Catalog entities`, + GroupID: "catalog", + Annotations: map[string]string{ + "package": "catalog", + }, + 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, + *catalog.CreateEntityTagAssignmentRequest, +) + +func newCreate() *cobra.Command { + cmd := &cobra.Command{} + + var createReq catalog.CreateEntityTagAssignmentRequest + createReq.TagAssignment = catalog.EntityTagAssignment{} + var createJson flags.JsonFlag + + cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&createReq.TagAssignment.TagValue, "tag-value", createReq.TagAssignment.TagValue, `The value of the tag.`) + + cmd.Use = "create ENTITY_NAME TAG_KEY ENTITY_TYPE" + cmd.Short = `Create an entity tag assignment.` + cmd.Long = `Create an entity tag assignment. + + Creates a tag assignment for an Unity Catalog entity. + + To add tags to Unity Catalog entities, you must own the entity or have the + following privileges: - **APPLY TAG** on the entity - **USE SCHEMA** on the + entity's parent schema - **USE CATALOG** on the entity's parent catalog + + To add a governed tag to Unity Catalog entities, you must also have the + **ASSIGN** or **MANAGE** permission on the tag policy. See [Manage tag policy + permissions]. + + [Manage tag policy permissions]: https://docs.databricks.com/aws/en/admin/tag-policies/manage-permissions + + Arguments: + ENTITY_NAME: The fully qualified name of the entity to which the tag is assigned + TAG_KEY: The key of the tag + ENTITY_TYPE: The type of the entity to which the tag is assigned. Allowed values are: + catalogs, schemas, tables, columns, volumes.` + + 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_name', 'tag_key', 'entity_type' 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 := createJson.Unmarshal(&createReq.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") { + createReq.TagAssignment.EntityName = args[0] + } + if !cmd.Flags().Changed("json") { + createReq.TagAssignment.TagKey = args[1] + } + if !cmd.Flags().Changed("json") { + createReq.TagAssignment.EntityType = args[2] + } + + response, err := w.EntityTagAssignments.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, + *catalog.DeleteEntityTagAssignmentRequest, +) + +func newDelete() *cobra.Command { + cmd := &cobra.Command{} + + var deleteReq catalog.DeleteEntityTagAssignmentRequest + + cmd.Use = "delete ENTITY_TYPE ENTITY_NAME TAG_KEY" + cmd.Short = `Delete an entity tag assignment.` + cmd.Long = `Delete an entity tag assignment. + + Deletes a tag assignment for an Unity Catalog entity by its key. + + To delete tags from Unity Catalog entities, you must own the entity or have + the following privileges: - **APPLY TAG** on the entity - **USE_SCHEMA** on + the entity's parent schema - **USE_CATALOG** on the entity's parent catalog + + To delete a governed tag from Unity Catalog entities, you must also have the + **ASSIGN** or **MANAGE** permission on the tag policy. See [Manage tag policy + permissions]. + + [Manage tag policy permissions]: https://docs.databricks.com/aws/en/admin/tag-policies/manage-permissions + + Arguments: + ENTITY_TYPE: The type of the entity to which the tag is assigned. Allowed values are: + catalogs, schemas, tables, columns, volumes. + ENTITY_NAME: The fully qualified name of the entity to which the tag is assigned + TAG_KEY: Required. The key of the tag to delete` + + 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) + + deleteReq.EntityType = args[0] + deleteReq.EntityName = args[1] + deleteReq.TagKey = args[2] + + err = w.EntityTagAssignments.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, + *catalog.GetEntityTagAssignmentRequest, +) + +func newGet() *cobra.Command { + cmd := &cobra.Command{} + + var getReq catalog.GetEntityTagAssignmentRequest + + cmd.Use = "get ENTITY_TYPE ENTITY_NAME TAG_KEY" + cmd.Short = `Get an entity tag assignment.` + cmd.Long = `Get an entity tag assignment. + + Gets a tag assignment for an Unity Catalog entity by tag key. + + Arguments: + ENTITY_TYPE: The type of the entity to which the tag is assigned. Allowed values are: + catalogs, schemas, tables, columns, volumes. + ENTITY_NAME: The fully qualified name of the entity to which the tag is assigned + TAG_KEY: Required. The key of the tag` + + 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) + + getReq.EntityType = args[0] + getReq.EntityName = args[1] + getReq.TagKey = args[2] + + response, err := w.EntityTagAssignments.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, + *catalog.ListEntityTagAssignmentsRequest, +) + +func newList() *cobra.Command { + cmd := &cobra.Command{} + + var listReq catalog.ListEntityTagAssignmentsRequest + + cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Optional.`) + cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Optional.`) + + cmd.Use = "list ENTITY_TYPE ENTITY_NAME" + cmd.Short = `List entity tag assignments.` + cmd.Long = `List entity tag assignments. + + List tag assignments for an Unity Catalog entity + + Arguments: + ENTITY_TYPE: The type of the entity to which the tag is assigned. Allowed values are: + catalogs, schemas, tables, columns, volumes. + ENTITY_NAME: The fully qualified name 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) + + listReq.EntityType = args[0] + listReq.EntityName = args[1] + + response := w.EntityTagAssignments.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, + *catalog.UpdateEntityTagAssignmentRequest, +) + +func newUpdate() *cobra.Command { + cmd := &cobra.Command{} + + var updateReq catalog.UpdateEntityTagAssignmentRequest + updateReq.TagAssignment = catalog.EntityTagAssignment{} + var updateJson flags.JsonFlag + + cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&updateReq.TagAssignment.TagValue, "tag-value", updateReq.TagAssignment.TagValue, `The value of the tag.`) + + cmd.Use = "update ENTITY_TYPE ENTITY_NAME TAG_KEY UPDATE_MASK" + cmd.Short = `Update an entity tag assignment.` + cmd.Long = `Update an entity tag assignment. + + Updates an existing tag assignment for an Unity Catalog entity. + + To update tags to Unity Catalog entities, you must own the entity or have the + following privileges: - **APPLY TAG** on the entity - **USE SCHEMA** on the + entity's parent schema - **USE CATALOG** on the entity's parent catalog + + To update a governed tag to Unity Catalog entities, you must also have the + **ASSIGN** or **MANAGE** permission on the tag policy. See [Manage tag policy + permissions]. + + [Manage tag policy permissions]: https://docs.databricks.com/aws/en/admin/tag-policies/manage-permissions + + Arguments: + ENTITY_TYPE: The type of the entity to which the tag is assigned. Allowed values are: + catalogs, schemas, tables, columns, volumes. + ENTITY_NAME: The fully qualified name of the entity to which the tag is assigned + TAG_KEY: The key of the tag + 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 := updateJson.Unmarshal(&updateReq.TagAssignment) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + updateReq.EntityType = args[0] + updateReq.EntityName = args[1] + updateReq.TagKey = args[2] + updateReq.UpdateMask = args[3] + + response, err := w.EntityTagAssignments.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 EntityTagAssignments diff --git a/cmd/workspace/genie/genie.go b/cmd/workspace/genie/genie.go index 70d15a014a..3238f68b99 100755 --- a/cmd/workspace/genie/genie.go +++ b/cmd/workspace/genie/genie.go @@ -37,6 +37,7 @@ func New() *cobra.Command { // Add methods cmd.AddCommand(newCreateMessage()) cmd.AddCommand(newDeleteConversation()) + cmd.AddCommand(newDeleteConversationMessage()) cmd.AddCommand(newExecuteMessageAttachmentQuery()) cmd.AddCommand(newExecuteMessageQuery()) cmd.AddCommand(newGetMessage()) @@ -44,8 +45,10 @@ func New() *cobra.Command { cmd.AddCommand(newGetMessageQueryResult()) cmd.AddCommand(newGetMessageQueryResultByAttachment()) cmd.AddCommand(newGetSpace()) + cmd.AddCommand(newListConversationMessages()) cmd.AddCommand(newListConversations()) cmd.AddCommand(newListSpaces()) + cmd.AddCommand(newSendMessageFeedback()) cmd.AddCommand(newStartConversation()) cmd.AddCommand(newTrashSpace()) @@ -220,6 +223,69 @@ func newDeleteConversation() *cobra.Command { return cmd } +// start delete-conversation-message 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 deleteConversationMessageOverrides []func( + *cobra.Command, + *dashboards.GenieDeleteConversationMessageRequest, +) + +func newDeleteConversationMessage() *cobra.Command { + cmd := &cobra.Command{} + + var deleteConversationMessageReq dashboards.GenieDeleteConversationMessageRequest + + cmd.Use = "delete-conversation-message SPACE_ID CONVERSATION_ID MESSAGE_ID" + cmd.Short = `Delete conversation message.` + cmd.Long = `Delete conversation message. + + Delete a conversation message. + + Arguments: + SPACE_ID: The ID associated with the Genie space where the message is located. + CONVERSATION_ID: The ID associated with the conversation. + MESSAGE_ID: The ID associated with the message to delete.` + + // 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 { + 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) + + deleteConversationMessageReq.SpaceId = args[0] + deleteConversationMessageReq.ConversationId = args[1] + deleteConversationMessageReq.MessageId = args[2] + + err = w.Genie.DeleteConversationMessage(ctx, deleteConversationMessageReq) + 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 deleteConversationMessageOverrides { + fn(cmd, &deleteConversationMessageReq) + } + + return cmd +} + // start execute-message-attachment-query command // Slice with functions to override default command behavior. @@ -301,7 +367,8 @@ func newExecuteMessageQuery() *cobra.Command { cmd.Short = `[Deprecated] Execute SQL query in a conversation message.` cmd.Long = `[Deprecated] Execute SQL query in a conversation message. - Execute the SQL query in the message. + DEPRECATED: Use [Execute Message Attachment + Query](:method:genie/executemessageattachmentquery) instead. Arguments: SPACE_ID: Genie space ID @@ -490,9 +557,8 @@ func newGetMessageQueryResult() *cobra.Command { cmd.Short = `[Deprecated] Get conversation message SQL query result.` cmd.Long = `[Deprecated] Get conversation message SQL query result. - Get the result of SQL query if the message has a query attachment. This is - only available if a message has a query attachment and the message status is - EXECUTING_QUERY. + DEPRECATED: Use [Get Message Attachment Query + Result](:method:genie/getmessageattachmentqueryresult) instead. Arguments: SPACE_ID: Genie space ID @@ -555,9 +621,8 @@ func newGetMessageQueryResultByAttachment() *cobra.Command { cmd.Short = `[Deprecated] Get conversation message SQL query result.` cmd.Long = `[Deprecated] Get conversation message SQL query result. - Get the result of SQL query if the message has a query attachment. This is - only available if a message has a query attachment and the message status is - EXECUTING_QUERY OR COMPLETED. + DEPRECATED: Use [Get Message Attachment Query + Result](:method:genie/getmessageattachmentqueryresult) instead. Arguments: SPACE_ID: Genie space ID @@ -660,6 +725,70 @@ func newGetSpace() *cobra.Command { return cmd } +// start list-conversation-messages 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 listConversationMessagesOverrides []func( + *cobra.Command, + *dashboards.GenieListConversationMessagesRequest, +) + +func newListConversationMessages() *cobra.Command { + cmd := &cobra.Command{} + + var listConversationMessagesReq dashboards.GenieListConversationMessagesRequest + + cmd.Flags().IntVar(&listConversationMessagesReq.PageSize, "page-size", listConversationMessagesReq.PageSize, `Maximum number of messages to return per page.`) + cmd.Flags().StringVar(&listConversationMessagesReq.PageToken, "page-token", listConversationMessagesReq.PageToken, `Token to get the next page of results.`) + + cmd.Use = "list-conversation-messages SPACE_ID CONVERSATION_ID" + cmd.Short = `List conversation messages.` + cmd.Long = `List conversation messages. + + List messages in a conversation + + Arguments: + SPACE_ID: The ID associated with the Genie space where the conversation is located + CONVERSATION_ID: The ID of the conversation to list messages from` + + // 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 { + 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) + + listConversationMessagesReq.SpaceId = args[0] + listConversationMessagesReq.ConversationId = args[1] + + response, err := w.Genie.ListConversationMessages(ctx, listConversationMessagesReq) + 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 listConversationMessagesOverrides { + fn(cmd, &listConversationMessagesReq) + } + + return cmd +} + // start list-conversations command // Slice with functions to override default command behavior. @@ -674,6 +803,7 @@ func newListConversations() *cobra.Command { var listConversationsReq dashboards.GenieListConversationsRequest + cmd.Flags().BoolVar(&listConversationsReq.IncludeAll, "include-all", listConversationsReq.IncludeAll, `Include all conversations in the space across all users.`) cmd.Flags().IntVar(&listConversationsReq.PageSize, "page-size", listConversationsReq.PageSize, `Maximum number of conversations to return per page.`) cmd.Flags().StringVar(&listConversationsReq.PageToken, "page-token", listConversationsReq.PageToken, `Token to get the next page of results.`) @@ -773,6 +903,101 @@ func newListSpaces() *cobra.Command { return cmd } +// start send-message-feedback 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 sendMessageFeedbackOverrides []func( + *cobra.Command, + *dashboards.GenieSendMessageFeedbackRequest, +) + +func newSendMessageFeedback() *cobra.Command { + cmd := &cobra.Command{} + + var sendMessageFeedbackReq dashboards.GenieSendMessageFeedbackRequest + var sendMessageFeedbackJson flags.JsonFlag + + cmd.Flags().Var(&sendMessageFeedbackJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&sendMessageFeedbackReq.FeedbackText, "feedback-text", sendMessageFeedbackReq.FeedbackText, `Optional text feedback that will be stored as a comment.`) + + cmd.Use = "send-message-feedback SPACE_ID CONVERSATION_ID MESSAGE_ID FEEDBACK_RATING" + cmd.Short = `Send message feedback.` + cmd.Long = `Send message feedback. + + Send feedback for a message. + + Arguments: + SPACE_ID: The ID associated with the Genie space where the message is located. + CONVERSATION_ID: The ID associated with the conversation. + MESSAGE_ID: The ID associated with the message to provide feedback for. + FEEDBACK_RATING: The rating (POSITIVE, NEGATIVE, or NONE). + Supported values: [NEGATIVE, NONE, POSITIVE]` + + // 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 { + if cmd.Flags().Changed("json") { + err := root.ExactArgs(3)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, provide only SPACE_ID, CONVERSATION_ID, MESSAGE_ID as positional arguments. Provide 'feedback_rating' 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 := sendMessageFeedbackJson.Unmarshal(&sendMessageFeedbackReq) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + sendMessageFeedbackReq.SpaceId = args[0] + sendMessageFeedbackReq.ConversationId = args[1] + sendMessageFeedbackReq.MessageId = args[2] + if !cmd.Flags().Changed("json") { + _, err = fmt.Sscan(args[3], &sendMessageFeedbackReq.FeedbackRating) + if err != nil { + return fmt.Errorf("invalid FEEDBACK_RATING: %s", args[3]) + } + } + + err = w.Genie.SendMessageFeedback(ctx, sendMessageFeedbackReq) + 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 sendMessageFeedbackOverrides { + fn(cmd, &sendMessageFeedbackReq) + } + + return cmd +} + // start start-conversation command // Slice with functions to override default command behavior. diff --git a/cmd/workspace/policies/policies.go b/cmd/workspace/policies/policies.go index bb55f60567..d915bf7809 100755 --- a/cmd/workspace/policies/policies.go +++ b/cmd/workspace/policies/policies.go @@ -33,10 +33,7 @@ func New() *cobra.Command { Annotations: map[string]string{ "package": "catalog", }, - - // This service is being previewed; hide from help output. - Hidden: true, - RunE: root.ReportUnknownSubcommand, + RunE: root.ReportUnknownSubcommand, } // Add methods @@ -110,7 +107,7 @@ func newCreatePolicy() *cobra.Command { Arguments: TO_PRINCIPALS: List of user or group names that the policy applies to. Required on create and optional on update. - FOR_SECURABLE_TYPE: Type of securables that the policy should take effect on. Only table is + FOR_SECURABLE_TYPE: Type of securables that the policy should take effect on. Only TABLE is supported at this moment. Required on create and optional on update. Supported values: [ CATALOG, @@ -444,7 +441,7 @@ func newUpdatePolicy() *cobra.Command { NAME: Required. The name of the policy to update. TO_PRINCIPALS: List of user or group names that the policy applies to. Required on create and optional on update. - FOR_SECURABLE_TYPE: Type of securables that the policy should take effect on. Only table is + FOR_SECURABLE_TYPE: Type of securables that the policy should take effect on. Only TABLE is supported at this moment. Required on create and optional on update. Supported values: [ CATALOG, diff --git a/cmd/workspace/rfa/rfa.go b/cmd/workspace/rfa/rfa.go new file mode 100755 index 0000000000..e5e310f4d9 --- /dev/null +++ b/cmd/workspace/rfa/rfa.go @@ -0,0 +1,308 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package rfa + +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/catalog" + "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: "rfa", + Short: `Request for Access enables customers to request access to and manage access request destinations for Unity Catalog securables.`, + Long: `Request for Access enables customers to request access to and manage access + request destinations for Unity Catalog securables. + + These APIs provide a standardized way to update, get, and request to access + request destinations. Fine-grained authorization ensures that only users with + appropriate permissions can manage access request destinations.`, + GroupID: "catalog", + Annotations: map[string]string{ + "package": "catalog", + }, + RunE: root.ReportUnknownSubcommand, + } + + // Add methods + cmd.AddCommand(newBatchCreateAccessRequests()) + cmd.AddCommand(newGetAccessRequestDestinations()) + cmd.AddCommand(newUpdateAccessRequestDestinations()) + + // Apply optional overrides to this command. + for _, fn := range cmdOverrides { + fn(cmd) + } + + return cmd +} + +// start batch-create-access-requests 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 batchCreateAccessRequestsOverrides []func( + *cobra.Command, + *catalog.BatchCreateAccessRequestsRequest, +) + +func newBatchCreateAccessRequests() *cobra.Command { + cmd := &cobra.Command{} + + var batchCreateAccessRequestsReq catalog.BatchCreateAccessRequestsRequest + var batchCreateAccessRequestsJson flags.JsonFlag + + cmd.Flags().Var(&batchCreateAccessRequestsJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + // TODO: array: requests + + cmd.Use = "batch-create-access-requests" + cmd.Short = `Create Access Requests.` + cmd.Long = `Create Access Requests. + + Creates access requests for Unity Catalog permissions for a specified + principal on a securable object. This Batch API can take in multiple + principals, securable objects, and permissions as the input and returns the + access request destinations for each. Principals must be unique across the API + call. + + The supported securable types are: "metastore", "catalog", "schema", "table", + "external_location", "connection", "credential", "function", + "registered_model", and "volume".` + + 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 := batchCreateAccessRequestsJson.Unmarshal(&batchCreateAccessRequestsReq) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + + response, err := w.Rfa.BatchCreateAccessRequests(ctx, batchCreateAccessRequestsReq) + 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 batchCreateAccessRequestsOverrides { + fn(cmd, &batchCreateAccessRequestsReq) + } + + return cmd +} + +// start get-access-request-destinations 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 getAccessRequestDestinationsOverrides []func( + *cobra.Command, + *catalog.GetAccessRequestDestinationsRequest, +) + +func newGetAccessRequestDestinations() *cobra.Command { + cmd := &cobra.Command{} + + var getAccessRequestDestinationsReq catalog.GetAccessRequestDestinationsRequest + + cmd.Use = "get-access-request-destinations SECURABLE_TYPE FULL_NAME" + cmd.Short = `Get Access Request Destinations.` + cmd.Long = `Get Access Request Destinations. + + Gets an array of access request destinations for the specified securable. Any + caller can see URL destinations or the destinations on the metastore. + Otherwise, only those with **BROWSE** permissions on the securable can see + destinations. + + The supported securable types are: "metastore", "catalog", "schema", "table", + "external_location", "connection", "credential", "function", + "registered_model", and "volume". + + Arguments: + SECURABLE_TYPE: The type of the securable. + FULL_NAME: The full name of the securable.` + + 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) + + getAccessRequestDestinationsReq.SecurableType = args[0] + getAccessRequestDestinationsReq.FullName = args[1] + + response, err := w.Rfa.GetAccessRequestDestinations(ctx, getAccessRequestDestinationsReq) + 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 getAccessRequestDestinationsOverrides { + fn(cmd, &getAccessRequestDestinationsReq) + } + + return cmd +} + +// start update-access-request-destinations 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 updateAccessRequestDestinationsOverrides []func( + *cobra.Command, + *catalog.UpdateAccessRequestDestinationsRequest, +) + +func newUpdateAccessRequestDestinations() *cobra.Command { + cmd := &cobra.Command{} + + var updateAccessRequestDestinationsReq catalog.UpdateAccessRequestDestinationsRequest + updateAccessRequestDestinationsReq.AccessRequestDestinations = catalog.AccessRequestDestinations{} + var updateAccessRequestDestinationsJson flags.JsonFlag + + cmd.Flags().Var(&updateAccessRequestDestinationsJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Use = "update-access-request-destinations UPDATE_MASK DESTINATIONS SECURABLE" + cmd.Short = `Update Access Request Destinations.` + cmd.Long = `Update Access Request Destinations. + + Updates the access request destinations for the given securable. The caller + must be a metastore admin, the owner of the securable, or a user that has the + **MANAGE** privilege on the securable in order to assign destinations. + Destinations cannot be updated for securables underneath schemas (tables, + volumes, functions, and models). For these securable types, destinations are + inherited from the parent securable. A maximum of 5 emails and 5 external + notification destinations (Slack, Microsoft Teams, and Generic Webhook + destinations) can be assigned to a securable. If a URL destination is + assigned, no other destinations can be set. + + The supported securable types are: "metastore", "catalog", "schema", "table", + "external_location", "connection", "credential", "function", + "registered_model", and "volume". + + Arguments: + 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. + DESTINATIONS: The access request destinations for the securable. + SECURABLE: The securable for which the access request destinations are being + retrieved.` + + 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 UPDATE_MASK as positional arguments. Provide 'destinations', 'securable' 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 := updateAccessRequestDestinationsJson.Unmarshal(&updateAccessRequestDestinationsReq.AccessRequestDestinations) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + updateAccessRequestDestinationsReq.UpdateMask = args[0] + if !cmd.Flags().Changed("json") { + _, err = fmt.Sscan(args[1], &updateAccessRequestDestinationsReq.AccessRequestDestinations.Destinations) + if err != nil { + return fmt.Errorf("invalid DESTINATIONS: %s", args[1]) + } + } + if !cmd.Flags().Changed("json") { + _, err = fmt.Sscan(args[2], &updateAccessRequestDestinationsReq.AccessRequestDestinations.Securable) + if err != nil { + return fmt.Errorf("invalid SECURABLE: %s", args[2]) + } + } + + response, err := w.Rfa.UpdateAccessRequestDestinations(ctx, updateAccessRequestDestinationsReq) + 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 updateAccessRequestDestinationsOverrides { + fn(cmd, &updateAccessRequestDestinationsReq) + } + + return cmd +} + +// end service Rfa diff --git a/cmd/workspace/tag-policies/tag-policies.go b/cmd/workspace/tag-policies/tag-policies.go new file mode 100755 index 0000000000..6bfe59d8ab --- /dev/null +++ b/cmd/workspace/tag-policies/tag-policies.go @@ -0,0 +1,375 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package tag_policies + +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-policies", + Short: `The Tag Policy API allows you to manage tag policies in Databricks.`, + Long: `The Tag Policy API allows you to manage tag policies in Databricks.`, + 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(newCreateTagPolicy()) + cmd.AddCommand(newDeleteTagPolicy()) + cmd.AddCommand(newGetTagPolicy()) + cmd.AddCommand(newListTagPolicies()) + cmd.AddCommand(newUpdateTagPolicy()) + + // Apply optional overrides to this command. + for _, fn := range cmdOverrides { + fn(cmd) + } + + return cmd +} + +// start create-tag-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 createTagPolicyOverrides []func( + *cobra.Command, + *tags.CreateTagPolicyRequest, +) + +func newCreateTagPolicy() *cobra.Command { + cmd := &cobra.Command{} + + var createTagPolicyReq tags.CreateTagPolicyRequest + createTagPolicyReq.TagPolicy = tags.TagPolicy{} + var createTagPolicyJson flags.JsonFlag + + cmd.Flags().Var(&createTagPolicyJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&createTagPolicyReq.TagPolicy.Description, "description", createTagPolicyReq.TagPolicy.Description, ``) + // TODO: array: values + + cmd.Use = "create-tag-policy TAG_KEY" + cmd.Short = `Create a new tag policy.` + cmd.Long = `Create a new tag policy. + + Creates a new tag policy.` + + 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 'tag_key' 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 := createTagPolicyJson.Unmarshal(&createTagPolicyReq.TagPolicy) + 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") { + createTagPolicyReq.TagPolicy.TagKey = args[0] + } + + response, err := w.TagPolicies.CreateTagPolicy(ctx, createTagPolicyReq) + 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 createTagPolicyOverrides { + fn(cmd, &createTagPolicyReq) + } + + return cmd +} + +// start delete-tag-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 deleteTagPolicyOverrides []func( + *cobra.Command, + *tags.DeleteTagPolicyRequest, +) + +func newDeleteTagPolicy() *cobra.Command { + cmd := &cobra.Command{} + + var deleteTagPolicyReq tags.DeleteTagPolicyRequest + + cmd.Use = "delete-tag-policy TAG_KEY" + cmd.Short = `Delete a tag policy.` + cmd.Long = `Delete a tag policy. + + Deletes a tag policy by its key.` + + 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) + + deleteTagPolicyReq.TagKey = args[0] + + err = w.TagPolicies.DeleteTagPolicy(ctx, deleteTagPolicyReq) + 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 deleteTagPolicyOverrides { + fn(cmd, &deleteTagPolicyReq) + } + + return cmd +} + +// start get-tag-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 getTagPolicyOverrides []func( + *cobra.Command, + *tags.GetTagPolicyRequest, +) + +func newGetTagPolicy() *cobra.Command { + cmd := &cobra.Command{} + + var getTagPolicyReq tags.GetTagPolicyRequest + + cmd.Use = "get-tag-policy TAG_KEY" + cmd.Short = `Get a tag policy.` + cmd.Long = `Get a tag policy. + + Gets a single tag policy by its key.` + + 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) + + getTagPolicyReq.TagKey = args[0] + + response, err := w.TagPolicies.GetTagPolicy(ctx, getTagPolicyReq) + 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 getTagPolicyOverrides { + fn(cmd, &getTagPolicyReq) + } + + return cmd +} + +// start list-tag-policies 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 listTagPoliciesOverrides []func( + *cobra.Command, + *tags.ListTagPoliciesRequest, +) + +func newListTagPolicies() *cobra.Command { + cmd := &cobra.Command{} + + var listTagPoliciesReq tags.ListTagPoliciesRequest + + cmd.Flags().IntVar(&listTagPoliciesReq.PageSize, "page-size", listTagPoliciesReq.PageSize, `The maximum number of results to return in this request.`) + cmd.Flags().StringVar(&listTagPoliciesReq.PageToken, "page-token", listTagPoliciesReq.PageToken, `An optional page token received from a previous list tag policies call.`) + + cmd.Use = "list-tag-policies" + cmd.Short = `List tag policies.` + cmd.Long = `List tag policies. + + Lists all tag policies in the account.` + + 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.TagPolicies.ListTagPolicies(ctx, listTagPoliciesReq) + 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 listTagPoliciesOverrides { + fn(cmd, &listTagPoliciesReq) + } + + return cmd +} + +// start update-tag-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 updateTagPolicyOverrides []func( + *cobra.Command, + *tags.UpdateTagPolicyRequest, +) + +func newUpdateTagPolicy() *cobra.Command { + cmd := &cobra.Command{} + + var updateTagPolicyReq tags.UpdateTagPolicyRequest + updateTagPolicyReq.TagPolicy = tags.TagPolicy{} + var updateTagPolicyJson flags.JsonFlag + + cmd.Flags().Var(&updateTagPolicyJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&updateTagPolicyReq.TagPolicy.Description, "description", updateTagPolicyReq.TagPolicy.Description, ``) + // TODO: array: values + + cmd.Use = "update-tag-policy TAG_KEY UPDATE_MASK" + cmd.Short = `Update an existing tag policy.` + cmd.Long = `Update an existing tag policy. + + Updates an existing tag policy. + + Arguments: + TAG_KEY: + 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(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 := updateTagPolicyJson.Unmarshal(&updateTagPolicyReq.TagPolicy) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + updateTagPolicyReq.TagKey = args[0] + updateTagPolicyReq.UpdateMask = args[1] + + response, err := w.TagPolicies.UpdateTagPolicy(ctx, updateTagPolicyReq) + 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 updateTagPolicyOverrides { + fn(cmd, &updateTagPolicyReq) + } + + return cmd +} + +// end service TagPolicies diff --git a/cmd/workspace/workspace-settings-v2/workspace-settings-v2.go b/cmd/workspace/workspace-settings-v2/workspace-settings-v2.go new file mode 100755 index 0000000000..9d50deb324 --- /dev/null +++ b/cmd/workspace/workspace-settings-v2/workspace-settings-v2.go @@ -0,0 +1,244 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package workspace_settings_v2 + +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/settingsv2" + "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: "workspace-settings-v2", + Short: `APIs to manage workspace level settings.`, + Long: `APIs to manage workspace level settings`, + GroupID: "settingsv2", + Annotations: map[string]string{ + "package": "settingsv2", + }, + + // This service is being previewed; hide from help output. + Hidden: true, + RunE: root.ReportUnknownSubcommand, + } + + // Add methods + cmd.AddCommand(newGetPublicWorkspaceSetting()) + cmd.AddCommand(newListWorkspaceSettingsMetadata()) + cmd.AddCommand(newPatchPublicWorkspaceSetting()) + + // Apply optional overrides to this command. + for _, fn := range cmdOverrides { + fn(cmd) + } + + return cmd +} + +// start get-public-workspace-setting 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 getPublicWorkspaceSettingOverrides []func( + *cobra.Command, + *settingsv2.GetPublicWorkspaceSettingRequest, +) + +func newGetPublicWorkspaceSetting() *cobra.Command { + cmd := &cobra.Command{} + + var getPublicWorkspaceSettingReq settingsv2.GetPublicWorkspaceSettingRequest + + cmd.Use = "get-public-workspace-setting NAME" + cmd.Short = `Get a workspace setting.` + cmd.Long = `Get a workspace setting. + + Get a setting value at workspace level` + + 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) + + getPublicWorkspaceSettingReq.Name = args[0] + + response, err := w.WorkspaceSettingsV2.GetPublicWorkspaceSetting(ctx, getPublicWorkspaceSettingReq) + 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 getPublicWorkspaceSettingOverrides { + fn(cmd, &getPublicWorkspaceSettingReq) + } + + return cmd +} + +// start list-workspace-settings-metadata 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 listWorkspaceSettingsMetadataOverrides []func( + *cobra.Command, + *settingsv2.ListWorkspaceSettingsMetadataRequest, +) + +func newListWorkspaceSettingsMetadata() *cobra.Command { + cmd := &cobra.Command{} + + var listWorkspaceSettingsMetadataReq settingsv2.ListWorkspaceSettingsMetadataRequest + + cmd.Flags().IntVar(&listWorkspaceSettingsMetadataReq.PageSize, "page-size", listWorkspaceSettingsMetadataReq.PageSize, `The maximum number of settings to return.`) + cmd.Flags().StringVar(&listWorkspaceSettingsMetadataReq.PageToken, "page-token", listWorkspaceSettingsMetadataReq.PageToken, `A page token, received from a previous ListWorkspaceSettingsMetadataRequest call.`) + + cmd.Use = "list-workspace-settings-metadata" + cmd.Short = `List valid setting keys and their metadata.` + cmd.Long = `List valid setting keys and their metadata. + + List valid setting keys and metadata. These settings are available to + referenced via [GET + /api/2.1/settings/{name}](#~1api~1workspace~1settingsv2~1getpublicworkspacesetting) + and [PATCH + /api/2.1/settings/{name}](#~1api~1workspace~1settingsv2~patchpublicworkspacesetting) + APIs` + + 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.WorkspaceSettingsV2.ListWorkspaceSettingsMetadata(ctx, listWorkspaceSettingsMetadataReq) + 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 listWorkspaceSettingsMetadataOverrides { + fn(cmd, &listWorkspaceSettingsMetadataReq) + } + + return cmd +} + +// start patch-public-workspace-setting 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 patchPublicWorkspaceSettingOverrides []func( + *cobra.Command, + *settingsv2.PatchPublicWorkspaceSettingRequest, +) + +func newPatchPublicWorkspaceSetting() *cobra.Command { + cmd := &cobra.Command{} + + var patchPublicWorkspaceSettingReq settingsv2.PatchPublicWorkspaceSettingRequest + patchPublicWorkspaceSettingReq.Setting = settingsv2.Setting{} + var patchPublicWorkspaceSettingJson flags.JsonFlag + + cmd.Flags().Var(&patchPublicWorkspaceSettingJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + // TODO: complex arg: aibi_dashboard_embedding_access_policy + // TODO: complex arg: aibi_dashboard_embedding_approved_domains + // TODO: complex arg: automatic_cluster_update_workspace + // TODO: complex arg: boolean_val + // TODO: complex arg: default_data_security_mode + // TODO: complex arg: effective_aibi_dashboard_embedding_access_policy + // TODO: complex arg: effective_aibi_dashboard_embedding_approved_domains + // TODO: complex arg: effective_automatic_cluster_update_workspace + // TODO: complex arg: effective_boolean_val + // TODO: complex arg: effective_default_data_security_mode + // TODO: complex arg: effective_integer_val + // TODO: complex arg: effective_personal_compute + // TODO: complex arg: effective_restrict_workspace_admins + // TODO: complex arg: effective_string_val + // TODO: complex arg: integer_val + cmd.Flags().StringVar(&patchPublicWorkspaceSettingReq.Setting.Name, "name", patchPublicWorkspaceSettingReq.Setting.Name, `Name of the setting.`) + // TODO: complex arg: personal_compute + // TODO: complex arg: restrict_workspace_admins + // TODO: complex arg: string_val + + cmd.Use = "patch-public-workspace-setting NAME" + cmd.Short = `Update a workspace setting.` + cmd.Long = `Update a workspace setting. + + Patch a setting value at workspace level` + + 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 := patchPublicWorkspaceSettingJson.Unmarshal(&patchPublicWorkspaceSettingReq.Setting) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags) + if err != nil { + return err + } + } + } + patchPublicWorkspaceSettingReq.Name = args[0] + + response, err := w.WorkspaceSettingsV2.PatchPublicWorkspaceSetting(ctx, patchPublicWorkspaceSettingReq) + 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 patchPublicWorkspaceSettingOverrides { + fn(cmd, &patchPublicWorkspaceSettingReq) + } + + return cmd +} + +// end service WorkspaceSettingsV2 diff --git a/experimental/python/databricks/bundles/jobs/_models/job.py b/experimental/python/databricks/bundles/jobs/_models/job.py index 98e060d752..e66e18f40b 100644 --- a/experimental/python/databricks/bundles/jobs/_models/job.py +++ b/experimental/python/databricks/bundles/jobs/_models/job.py @@ -191,7 +191,7 @@ class Job(Resource): The id of the user specified usage policy to use for this job. If not specified, a default usage policy may be applied when creating or modifying the job. - See `effective_budget_policy_id` for the budget policy used by this workload. + See `effective_usage_policy_id` for the usage policy used by this workload. """ webhook_notifications: VariableOrOptional[WebhookNotifications] = None @@ -331,7 +331,7 @@ class JobDict(TypedDict, total=False): The id of the user specified usage policy to use for this job. If not specified, a default usage policy may be applied when creating or modifying the job. - See `effective_budget_policy_id` for the budget policy used by this workload. + See `effective_usage_policy_id` for the usage policy used by this workload. """ webhook_notifications: VariableOrOptional[WebhookNotificationsParam] diff --git a/go.mod b/go.mod index 53eaab7389..fc77a2768e 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/BurntSushi/toml v1.5.0 // MIT github.com/Masterminds/semver/v3 v3.4.0 // MIT github.com/briandowns/spinner v1.23.1 // Apache 2.0 - github.com/databricks/databricks-sdk-go v0.80.0 // Apache 2.0 + github.com/databricks/databricks-sdk-go v0.81.0 // Apache 2.0 github.com/fatih/color v1.18.0 // MIT github.com/google/uuid v1.6.0 // BSD-3-Clause github.com/gorilla/mux v1.8.1 // BSD 3-Clause diff --git a/go.sum b/go.sum index f0913f7e52..95976add6f 100644 --- a/go.sum +++ b/go.sum @@ -33,8 +33,8 @@ github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZ github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/cyphar/filepath-securejoin v0.4.1 h1:JyxxyPEaktOD+GAnqIqTf9A8tHyAG22rowi7HkoSU1s= github.com/cyphar/filepath-securejoin v0.4.1/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI= -github.com/databricks/databricks-sdk-go v0.80.0 h1:KBOgrKB80gHd5XqSP6uOpJoiJiWTzOeqKpoTmM6MzX8= -github.com/databricks/databricks-sdk-go v0.80.0/go.mod h1:xBtjeP9nq+6MgTewZW1EcbRkD7aDY9gZvcRPcwPhZjw= +github.com/databricks/databricks-sdk-go v0.81.0 h1:ka+1w6TG2ne+1IfFgJ6g1Sm4JEAsSClNU6z1mZQSqak= +github.com/databricks/databricks-sdk-go v0.81.0/go.mod h1:xBtjeP9nq+6MgTewZW1EcbRkD7aDY9gZvcRPcwPhZjw= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/libs/cmdgroup/command.go b/libs/cmdgroup/command.go index 388dbe62b3..c64bac9c35 100644 --- a/libs/cmdgroup/command.go +++ b/libs/cmdgroup/command.go @@ -106,3 +106,38 @@ func tmpl(w io.Writer, text string, data any) error { template.Must(t.Parse(text)) return t.Execute(w, data) } + +// FilterGroups returns command groups that have at least one available (non-hidden) command. +// Empty groups or groups with only hidden commands are filtered out from the help output. +// Commands that belong to filtered groups will have their GroupID cleared. +func FilterGroups(groups []cobra.Group, allCommands []*cobra.Command) []cobra.Group { + var filteredGroups []cobra.Group + + // Create a map to track which groups have available commands + groupHasAvailableCommands := make(map[string]bool) + + // Check each command to see if it belongs to a group and is available + for _, cmd := range allCommands { + if cmd.GroupID != "" && cmd.IsAvailableCommand() { + groupHasAvailableCommands[cmd.GroupID] = true + } + } + + // Collect groups that have available commands + validGroupIDs := make(map[string]bool) + for _, group := range groups { + if groupHasAvailableCommands[group.ID] { + filteredGroups = append(filteredGroups, group) + validGroupIDs[group.ID] = true + } + } + + // Clear GroupID for commands that belong to filtered groups + for _, cmd := range allCommands { + if cmd.GroupID != "" && !validGroupIDs[cmd.GroupID] { + cmd.GroupID = "" + } + } + + return filteredGroups +}