From ea4ff6dc7a05ee27586167307e8798438151cc31 Mon Sep 17 00:00:00 2001 From: Pawel Kosiec Date: Tue, 10 Mar 2026 17:20:18 +0100 Subject: [PATCH 1/2] Bump Databricks Go SDK to 0.119.0 --- .codegen/_openapi_sha | 2 +- .gitattributes | 2 + NEXT_CHANGELOG.md | 2 +- acceptance/bundle/refschema/out.fields.txt | 6 + .../internal/schema/annotations_openapi.yml | 24 +- .../schema/annotations_openapi_overrides.yml | 3 + .../validation/generated/required_fields.go | 31 +- bundle/schema/jsonschema.json | 69 +- bundle/schema/jsonschema_for_docs.json | 45 +- cmd/account/log-delivery/log-delivery.go | 32 +- cmd/workspace/apps/apps.go | 2 + cmd/workspace/cmd.go | 4 + .../data-classification.go | 324 +++++++ .../feature-engineering.go | 12 +- cmd/workspace/genie/genie.go | 336 +++++++ cmd/workspace/groups.go | 4 + .../knowledge-assistants.go | 853 ++++++++++++++++++ cmd/workspace/permissions/permissions.go | 24 +- .../workspace-entity-tag-assignments.go | 10 +- go.mod | 2 +- go.sum | 4 +- 21 files changed, 1730 insertions(+), 61 deletions(-) create mode 100755 cmd/workspace/data-classification/data-classification.go create mode 100755 cmd/workspace/knowledge-assistants/knowledge-assistants.go diff --git a/.codegen/_openapi_sha b/.codegen/_openapi_sha index 4e0a18f572..ddc7b70897 100644 --- a/.codegen/_openapi_sha +++ b/.codegen/_openapi_sha @@ -1 +1 @@ -4ad0f0856225e3ebc6bb11392d09d63a19e6d140 \ No newline at end of file +a7c320a6b531263c8fa45619c1565b63849750e5 \ No newline at end of file diff --git a/.gitattributes b/.gitattributes index 6de2907403..7cb16bf826 100644 --- a/.gitattributes +++ b/.gitattributes @@ -77,6 +77,7 @@ cmd/workspace/current-user/current-user.go linguist-generated=true cmd/workspace/dashboard-email-subscriptions/dashboard-email-subscriptions.go linguist-generated=true cmd/workspace/dashboard-widgets/dashboard-widgets.go linguist-generated=true cmd/workspace/dashboards/dashboards.go linguist-generated=true +cmd/workspace/data-classification/data-classification.go linguist-generated=true cmd/workspace/data-quality/data-quality.go linguist-generated=true cmd/workspace/data-sources/data-sources.go linguist-generated=true cmd/workspace/database/database.go linguist-generated=true @@ -107,6 +108,7 @@ cmd/workspace/instance-pools/instance-pools.go linguist-generated=true cmd/workspace/instance-profiles/instance-profiles.go linguist-generated=true cmd/workspace/ip-access-lists/ip-access-lists.go linguist-generated=true cmd/workspace/jobs/jobs.go linguist-generated=true +cmd/workspace/knowledge-assistants/knowledge-assistants.go linguist-generated=true cmd/workspace/lakeview-embedded/lakeview-embedded.go linguist-generated=true cmd/workspace/lakeview/lakeview.go linguist-generated=true cmd/workspace/libraries/libraries.go linguist-generated=true diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index ed11712f51..37b08bcf3c 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -8,6 +8,6 @@ * Modify grants to use SDK types ([#4666](https://github.com/databricks/cli/pull/4666)) ### Dependency updates -- Bump databricks-sdk-go from v0.112.0 to v0.117.0. +- Bump databricks-sdk-go from v0.112.0 to v0.119.0. ([#4631](https://github.com/databricks/cli/pull/4631)) ### API Changes diff --git a/acceptance/bundle/refschema/out.fields.txt b/acceptance/bundle/refschema/out.fields.txt index eac815bff4..a942c70c64 100644 --- a/acceptance/bundle/refschema/out.fields.txt +++ b/acceptance/bundle/refschema/out.fields.txt @@ -212,6 +212,12 @@ resources.apps.*.service_principal_id int64 ALL resources.apps.*.service_principal_name string ALL resources.apps.*.source_code_path string INPUT resources.apps.*.space string ALL +resources.apps.*.telemetry_export_destinations []apps.TelemetryExportDestination ALL +resources.apps.*.telemetry_export_destinations[*] apps.TelemetryExportDestination ALL +resources.apps.*.telemetry_export_destinations[*].unity_catalog *apps.UnityCatalog ALL +resources.apps.*.telemetry_export_destinations[*].unity_catalog.logs_table string ALL +resources.apps.*.telemetry_export_destinations[*].unity_catalog.metrics_table string ALL +resources.apps.*.telemetry_export_destinations[*].unity_catalog.traces_table string ALL resources.apps.*.update_time string ALL resources.apps.*.updater string ALL resources.apps.*.url string ALL diff --git a/bundle/internal/schema/annotations_openapi.yml b/bundle/internal/schema/annotations_openapi.yml index ad92c6a021..a014f38053 100644 --- a/bundle/internal/schema/annotations_openapi.yml +++ b/bundle/internal/schema/annotations_openapi.yml @@ -155,6 +155,7 @@ github.com/databricks/cli/bundle/config/resources.App: Name of the space this app belongs to. "x-databricks-preview": |- PRIVATE + "telemetry_export_destinations": {} "update_time": "description": |- The update time of the app. Formatted timestamp in ISO 6801. @@ -1064,9 +1065,6 @@ github.com/databricks/cli/bundle/config/resources.SqlWarehouse: Warehouse type: `PRO` or `CLASSIC`. If you want to use serverless compute, you must set to `PRO` and also set the field `enable_serverless_compute` to `true`. github.com/databricks/cli/bundle/config/resources.SyncedDatabaseTable: - "_": - "description": |- - Next field marker: 18 "data_synchronization_status": "description": |- Synced Table data synchronization status @@ -1518,6 +1516,26 @@ github.com/databricks/databricks-sdk-go/service/apps.GitSource: "tag": "description": |- Git tag to checkout. +github.com/databricks/databricks-sdk-go/service/apps.TelemetryExportDestination: + "_": + "description": |- + A single telemetry export destination with its configuration and status. + "unity_catalog": + "description": |- + Unity Catalog Destinations for OTEL telemetry export. +github.com/databricks/databricks-sdk-go/service/apps.UnityCatalog: + "_": + "description": |- + Unity Catalog Destinations for OTEL telemetry export. + "logs_table": + "description": |- + Unity Catalog table for OTEL logs. + "metrics_table": + "description": |- + Unity Catalog table for OTEL metrics. + "traces_table": + "description": |- + Unity Catalog table for OTEL traces (spans). github.com/databricks/databricks-sdk-go/service/catalog.AwsSqsQueue: "managed_resource_id": "description": |- diff --git a/bundle/internal/schema/annotations_openapi_overrides.yml b/bundle/internal/schema/annotations_openapi_overrides.yml index 4496dd37f1..18a05dfb83 100644 --- a/bundle/internal/schema/annotations_openapi_overrides.yml +++ b/bundle/internal/schema/annotations_openapi_overrides.yml @@ -74,6 +74,9 @@ github.com/databricks/cli/bundle/config/resources.App: "source_code_path": "description": |- PLACEHOLDER + "telemetry_export_destinations": + "description": |- + PLACEHOLDER "usage_policy_id": "description": |- PLACEHOLDER diff --git a/bundle/internal/validation/generated/required_fields.go b/bundle/internal/validation/generated/required_fields.go index 857caa2523..7505453f8e 100644 --- a/bundle/internal/validation/generated/required_fields.go +++ b/bundle/internal/validation/generated/required_fields.go @@ -19,21 +19,22 @@ var RequiredFields = map[string][]string{ "resources.alerts.*.schedule": {"quartz_cron_schedule", "timezone_id"}, "resources.apps.*": {"name"}, - "resources.apps.*.active_deployment.git_source.git_repository": {"provider", "url"}, - "resources.apps.*.config.env[*]": {"name"}, - "resources.apps.*.git_repository": {"provider", "url"}, - "resources.apps.*.git_source.git_repository": {"provider", "url"}, - "resources.apps.*.pending_deployment.git_source.git_repository": {"provider", "url"}, - "resources.apps.*.permissions[*]": {"level"}, - "resources.apps.*.resources[*]": {"name"}, - "resources.apps.*.resources[*].database": {"database_name", "instance_name", "permission"}, - "resources.apps.*.resources[*].experiment": {"experiment_id", "permission"}, - "resources.apps.*.resources[*].genie_space": {"name", "permission", "space_id"}, - "resources.apps.*.resources[*].job": {"id", "permission"}, - "resources.apps.*.resources[*].secret": {"key", "permission", "scope"}, - "resources.apps.*.resources[*].serving_endpoint": {"name", "permission"}, - "resources.apps.*.resources[*].sql_warehouse": {"id", "permission"}, - "resources.apps.*.resources[*].uc_securable": {"permission", "securable_full_name", "securable_type"}, + "resources.apps.*.active_deployment.git_source.git_repository": {"provider", "url"}, + "resources.apps.*.config.env[*]": {"name"}, + "resources.apps.*.git_repository": {"provider", "url"}, + "resources.apps.*.git_source.git_repository": {"provider", "url"}, + "resources.apps.*.pending_deployment.git_source.git_repository": {"provider", "url"}, + "resources.apps.*.permissions[*]": {"level"}, + "resources.apps.*.resources[*]": {"name"}, + "resources.apps.*.resources[*].database": {"database_name", "instance_name", "permission"}, + "resources.apps.*.resources[*].experiment": {"experiment_id", "permission"}, + "resources.apps.*.resources[*].genie_space": {"name", "permission", "space_id"}, + "resources.apps.*.resources[*].job": {"id", "permission"}, + "resources.apps.*.resources[*].secret": {"key", "permission", "scope"}, + "resources.apps.*.resources[*].serving_endpoint": {"name", "permission"}, + "resources.apps.*.resources[*].sql_warehouse": {"id", "permission"}, + "resources.apps.*.resources[*].uc_securable": {"permission", "securable_full_name", "securable_type"}, + "resources.apps.*.telemetry_export_destinations[*].unity_catalog": {"logs_table", "metrics_table", "traces_table"}, "resources.catalogs.*": {"name"}, diff --git a/bundle/schema/jsonschema.json b/bundle/schema/jsonschema.json index a74fbb6013..217e688796 100644 --- a/bundle/schema/jsonschema.json +++ b/bundle/schema/jsonschema.json @@ -219,6 +219,9 @@ "x-databricks-preview": "PRIVATE", "doNotSuggest": true }, + "telemetry_export_destinations": { + "$ref": "#/$defs/slice/github.com/databricks/databricks-sdk-go/service/apps.TelemetryExportDestination" + }, "usage_policy_id": { "$ref": "#/$defs/string" }, @@ -2170,7 +2173,6 @@ "oneOf": [ { "type": "object", - "description": "Next field marker: 18", "properties": { "database_instance_name": { "$ref": "#/$defs/string" @@ -3755,6 +3757,57 @@ } ] }, + "apps.TelemetryExportDestination": { + "oneOf": [ + { + "type": "object", + "description": "A single telemetry export destination with its configuration and status.", + "properties": { + "unity_catalog": { + "description": "Unity Catalog Destinations for OTEL telemetry export.", + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/apps.UnityCatalog" + } + }, + "additionalProperties": false + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, + "apps.UnityCatalog": { + "oneOf": [ + { + "type": "object", + "description": "Unity Catalog Destinations for OTEL telemetry export.", + "properties": { + "logs_table": { + "description": "Unity Catalog table for OTEL logs.", + "$ref": "#/$defs/string" + }, + "metrics_table": { + "description": "Unity Catalog table for OTEL metrics.", + "$ref": "#/$defs/string" + }, + "traces_table": { + "description": "Unity Catalog table for OTEL traces (spans).", + "$ref": "#/$defs/string" + } + }, + "additionalProperties": false, + "required": [ + "logs_table", + "metrics_table", + "traces_table" + ] + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, "catalog.AwsSqsQueue": { "oneOf": [ { @@ -11290,6 +11343,20 @@ } ] }, + "apps.TelemetryExportDestination": { + "oneOf": [ + { + "type": "array", + "items": { + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/apps.TelemetryExportDestination" + } + }, + { + "type": "string", + "pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)+)\\}" + } + ] + }, "catalog.MonitorMetric": { "oneOf": [ { diff --git a/bundle/schema/jsonschema_for_docs.json b/bundle/schema/jsonschema_for_docs.json index fb2312a96e..50af5b7eb0 100644 --- a/bundle/schema/jsonschema_for_docs.json +++ b/bundle/schema/jsonschema_for_docs.json @@ -174,6 +174,9 @@ "doNotSuggest": true, "x-since-version": "v0.290.0" }, + "telemetry_export_destinations": { + "$ref": "#/$defs/slice/github.com/databricks/databricks-sdk-go/service/apps.TelemetryExportDestination" + }, "usage_policy_id": { "$ref": "#/$defs/string", "x-since-version": "v0.283.0" @@ -2057,7 +2060,6 @@ }, "resources.SyncedDatabaseTable": { "type": "object", - "description": "Next field marker: 18", "properties": { "database_instance_name": { "$ref": "#/$defs/string", @@ -3392,6 +3394,41 @@ }, "additionalProperties": false }, + "apps.TelemetryExportDestination": { + "type": "object", + "description": "A single telemetry export destination with its configuration and status.", + "properties": { + "unity_catalog": { + "description": "Unity Catalog Destinations for OTEL telemetry export.", + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/apps.UnityCatalog" + } + }, + "additionalProperties": false + }, + "apps.UnityCatalog": { + "type": "object", + "description": "Unity Catalog Destinations for OTEL telemetry export.", + "properties": { + "logs_table": { + "description": "Unity Catalog table for OTEL logs.", + "$ref": "#/$defs/string" + }, + "metrics_table": { + "description": "Unity Catalog table for OTEL metrics.", + "$ref": "#/$defs/string" + }, + "traces_table": { + "description": "Unity Catalog table for OTEL traces (spans).", + "$ref": "#/$defs/string" + } + }, + "additionalProperties": false, + "required": [ + "logs_table", + "metrics_table", + "traces_table" + ] + }, "catalog.AwsSqsQueue": { "type": "object", "properties": { @@ -9156,6 +9193,12 @@ "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/apps.EnvVar" } }, + "apps.TelemetryExportDestination": { + "type": "array", + "items": { + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/apps.TelemetryExportDestination" + } + }, "catalog.MonitorMetric": { "type": "array", "items": { diff --git a/cmd/account/log-delivery/log-delivery.go b/cmd/account/log-delivery/log-delivery.go index b69051616f..0a0f650936 100755 --- a/cmd/account/log-delivery/log-delivery.go +++ b/cmd/account/log-delivery/log-delivery.go @@ -22,9 +22,9 @@ func New() *cobra.Command { Use: "log-delivery", Short: `These APIs manage log delivery configurations for this account.`, Long: `These APIs manage log delivery configurations for this account. The two - supported log types for this API are _billable usage logs_ and _audit logs_. - This feature is in Public Preview. This feature works with all account ID - types. + supported log types for this API are _billable usage logs_ (AWS only) and + _audit logs_ (AWS and GCP). This feature is in Public Preview. This feature + works with all account ID types. Log delivery works with all account types. However, if your account is on the E2 version of the platform or on a select custom plan that allows multiple @@ -32,7 +32,7 @@ func New() *cobra.Command { destinations for each workspace. Log delivery status is also provided to know the latest status of log delivery attempts. - The high-level flow of billable usage delivery: + The high-level flow of billable usage delivery (AWS only): 1. **Create storage**: In AWS, [create a new AWS S3 bucket] with a specific bucket policy. Using Databricks APIs, call the Account API to create a @@ -56,11 +56,12 @@ func New() *cobra.Command { delivers logs related to the specified workspaces. You can create multiple types of delivery configurations per account. - For billable usage delivery: * For more information about billable usage logs, - see [Billable usage log delivery]. For the CSV schema, see the [Usage page]. * - The delivery location is //billable-usage/csv/, where - is the name of the optional delivery path prefix you set up during - log delivery configuration. Files are named + For billable usage delivery (AWS only): * For more information about billable + usage logs, see [Billable usage log delivery]. For the CSV schema, see the + [Usage page]. * The delivery location is + //billable-usage/csv/, where is the name of + the optional delivery path prefix you set up during log delivery + configuration. Files are named workspaceId=-usageMonth=.csv. * All billable usage logs apply to specific workspaces (_workspace level_ logs). You can aggregate usage for your entire account by creating an _account level_ delivery configuration @@ -68,9 +69,9 @@ func New() *cobra.Command { The files are delivered daily by overwriting the month's CSV file for each workspace. - For audit log delivery: * For more information about about audit log delivery, - see [Audit log delivery], which includes information about the used JSON - schema. * The delivery location is + For audit log delivery (AWS and GCP): * For more information about about audit + log delivery, see Audit log delivery [AWS] or [GCP], which includes + information about the used JSON schema. * The delivery location is //workspaceId=/date=/auditlogs_.json. Files may get overwritten with the same content multiple times to achieve exactly-once delivery. * If the audit log delivery configuration included @@ -78,11 +79,12 @@ func New() *cobra.Command { are delivered. If the log delivery configuration applies to the entire account (_account level_ delivery configuration), the audit log delivery includes workspace-level audit logs for all workspaces in the account as well as - account-level audit logs. See [Audit log delivery] for details. * Auditable - events are typically available in logs within 15 minutes. + account-level audit logs. See Audit log delivery [AWS] or [GCP] for details. * + Auditable events are typically available in logs within 15 minutes. - [Audit log delivery]: https://docs.databricks.com/administration-guide/account-settings/audit-logs.html + [AWS]: https://docs.databricks.com/administration-guide/account-settings/audit-logs.html [Billable usage log delivery]: https://docs.databricks.com/administration-guide/account-settings/billable-usage-delivery.html + [GCP]: https://docs.databricks.com/gcp/en/admin/account-settings/audit-logs [Usage page]: https://docs.databricks.com/administration-guide/account-settings/usage.html [create a new AWS S3 bucket]: https://docs.databricks.com/administration-guide/account-api/aws-storage.html`, GroupID: "billing", diff --git a/cmd/workspace/apps/apps.go b/cmd/workspace/apps/apps.go index 139f0989d1..a5be38b603 100755 --- a/cmd/workspace/apps/apps.go +++ b/cmd/workspace/apps/apps.go @@ -100,6 +100,7 @@ func newCreate() *cobra.Command { // TODO: complex arg: pending_deployment // TODO: array: resources cmd.Flags().StringVar(&createReq.App.Space, "space", createReq.App.Space, `Name of the space this app belongs to.`) + // TODO: array: telemetry_export_destinations cmd.Flags().StringVar(&createReq.App.UsagePolicyId, "usage-policy-id", createReq.App.UsagePolicyId, ``) // TODO: array: user_api_scopes @@ -1536,6 +1537,7 @@ func newUpdate() *cobra.Command { // TODO: complex arg: pending_deployment // TODO: array: resources cmd.Flags().StringVar(&updateReq.App.Space, "space", updateReq.App.Space, `Name of the space this app belongs to.`) + // TODO: array: telemetry_export_destinations cmd.Flags().StringVar(&updateReq.App.UsagePolicyId, "usage-policy-id", updateReq.App.UsagePolicyId, ``) // TODO: array: user_api_scopes diff --git a/cmd/workspace/cmd.go b/cmd/workspace/cmd.go index 902884bdfe..26ed4f5ce2 100755 --- a/cmd/workspace/cmd.go +++ b/cmd/workspace/cmd.go @@ -30,6 +30,7 @@ import ( current_user "github.com/databricks/cli/cmd/workspace/current-user" dashboard_widgets "github.com/databricks/cli/cmd/workspace/dashboard-widgets" dashboards "github.com/databricks/cli/cmd/workspace/dashboards" + data_classification "github.com/databricks/cli/cmd/workspace/data-classification" data_quality "github.com/databricks/cli/cmd/workspace/data-quality" data_sources "github.com/databricks/cli/cmd/workspace/data-sources" database "github.com/databricks/cli/cmd/workspace/database" @@ -51,6 +52,7 @@ import ( instance_profiles "github.com/databricks/cli/cmd/workspace/instance-profiles" ip_access_lists "github.com/databricks/cli/cmd/workspace/ip-access-lists" jobs "github.com/databricks/cli/cmd/workspace/jobs" + knowledge_assistants "github.com/databricks/cli/cmd/workspace/knowledge-assistants" lakeview "github.com/databricks/cli/cmd/workspace/lakeview" lakeview_embedded "github.com/databricks/cli/cmd/workspace/lakeview-embedded" libraries "github.com/databricks/cli/cmd/workspace/libraries" @@ -155,6 +157,7 @@ func All() []*cobra.Command { out = append(out, current_user.New()) out = append(out, dashboard_widgets.New()) out = append(out, dashboards.New()) + out = append(out, data_classification.New()) out = append(out, data_quality.New()) out = append(out, data_sources.New()) out = append(out, database.New()) @@ -176,6 +179,7 @@ func All() []*cobra.Command { out = append(out, instance_profiles.New()) out = append(out, ip_access_lists.New()) out = append(out, jobs.New()) + out = append(out, knowledge_assistants.New()) out = append(out, lakeview.New()) out = append(out, lakeview_embedded.New()) out = append(out, libraries.New()) diff --git a/cmd/workspace/data-classification/data-classification.go b/cmd/workspace/data-classification/data-classification.go new file mode 100755 index 0000000000..3403a7772c --- /dev/null +++ b/cmd/workspace/data-classification/data-classification.go @@ -0,0 +1,324 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package data_classification + +import ( + "strings" + + "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/common/types/fieldmask" + "github.com/databricks/databricks-sdk-go/service/dataclassification" + "github.com/spf13/cobra" +) + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var cmdOverrides []func(*cobra.Command) + +func New() *cobra.Command { + cmd := &cobra.Command{ + Use: "data-classification", + Short: `Manage data classification for Unity Catalog catalogs.`, + Long: `Manage data classification for Unity Catalog catalogs. Data classification + automatically identifies and tags sensitive data (PII) in Unity Catalog + tables. Each catalog can have at most one configuration resource that controls + scanning behavior and auto-tagging rules.`, + GroupID: "dataclassification", + + // This service is being previewed; hide from help output. + Hidden: true, + RunE: root.ReportUnknownSubcommand, + } + + // Add methods + cmd.AddCommand(newCreateCatalogConfig()) + cmd.AddCommand(newDeleteCatalogConfig()) + cmd.AddCommand(newGetCatalogConfig()) + cmd.AddCommand(newUpdateCatalogConfig()) + + // Apply optional overrides to this command. + for _, fn := range cmdOverrides { + fn(cmd) + } + + return cmd +} + +// start create-catalog-config 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 createCatalogConfigOverrides []func( + *cobra.Command, + *dataclassification.CreateCatalogConfigRequest, +) + +func newCreateCatalogConfig() *cobra.Command { + cmd := &cobra.Command{} + + var createCatalogConfigReq dataclassification.CreateCatalogConfigRequest + createCatalogConfigReq.CatalogConfig = dataclassification.CatalogConfig{} + var createCatalogConfigJson flags.JsonFlag + + cmd.Flags().Var(&createCatalogConfigJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + // TODO: array: auto_tag_configs + // TODO: complex arg: included_schemas + cmd.Flags().StringVar(&createCatalogConfigReq.CatalogConfig.Name, "name", createCatalogConfigReq.CatalogConfig.Name, `Resource name in the format: catalogs/{catalog_name}/config.`) + + cmd.Use = "create-catalog-config PARENT" + cmd.Short = `Create config for a catalog.` + cmd.Long = `Create config for a catalog. + + Create Data Classification configuration for a catalog. + + Creates a new config resource, which enables Data Classification for the + specified catalog. - The config must not already exist for the catalog. + + Arguments: + PARENT: Parent resource in the format: catalogs/{catalog_name}` + + 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 := createCatalogConfigJson.Unmarshal(&createCatalogConfigReq.CatalogConfig) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnostics(ctx, diags) + if err != nil { + return err + } + } + } + createCatalogConfigReq.Parent = args[0] + + response, err := w.DataClassification.CreateCatalogConfig(ctx, createCatalogConfigReq) + 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 createCatalogConfigOverrides { + fn(cmd, &createCatalogConfigReq) + } + + return cmd +} + +// start delete-catalog-config 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 deleteCatalogConfigOverrides []func( + *cobra.Command, + *dataclassification.DeleteCatalogConfigRequest, +) + +func newDeleteCatalogConfig() *cobra.Command { + cmd := &cobra.Command{} + + var deleteCatalogConfigReq dataclassification.DeleteCatalogConfigRequest + + cmd.Use = "delete-catalog-config NAME" + cmd.Short = `Delete config for a catalog.` + cmd.Long = `Delete config for a catalog. + + Delete Data Classification configuration for a catalog. + + Arguments: + NAME: Resource name in the format: catalogs/{catalog_name}/config` + + 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) + + deleteCatalogConfigReq.Name = args[0] + + err = w.DataClassification.DeleteCatalogConfig(ctx, deleteCatalogConfigReq) + 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 deleteCatalogConfigOverrides { + fn(cmd, &deleteCatalogConfigReq) + } + + return cmd +} + +// start get-catalog-config 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 getCatalogConfigOverrides []func( + *cobra.Command, + *dataclassification.GetCatalogConfigRequest, +) + +func newGetCatalogConfig() *cobra.Command { + cmd := &cobra.Command{} + + var getCatalogConfigReq dataclassification.GetCatalogConfigRequest + + cmd.Use = "get-catalog-config NAME" + cmd.Short = `Get config for a catalog.` + cmd.Long = `Get config for a catalog. + + Get the Data Classification configuration for a catalog. + + Arguments: + NAME: Resource name in the format: catalogs/{catalog_name}/config` + + 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) + + getCatalogConfigReq.Name = args[0] + + response, err := w.DataClassification.GetCatalogConfig(ctx, getCatalogConfigReq) + 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 getCatalogConfigOverrides { + fn(cmd, &getCatalogConfigReq) + } + + return cmd +} + +// start update-catalog-config 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 updateCatalogConfigOverrides []func( + *cobra.Command, + *dataclassification.UpdateCatalogConfigRequest, +) + +func newUpdateCatalogConfig() *cobra.Command { + cmd := &cobra.Command{} + + var updateCatalogConfigReq dataclassification.UpdateCatalogConfigRequest + updateCatalogConfigReq.CatalogConfig = dataclassification.CatalogConfig{} + var updateCatalogConfigJson flags.JsonFlag + + cmd.Flags().Var(&updateCatalogConfigJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + // TODO: array: auto_tag_configs + // TODO: complex arg: included_schemas + cmd.Flags().StringVar(&updateCatalogConfigReq.CatalogConfig.Name, "name", updateCatalogConfigReq.CatalogConfig.Name, `Resource name in the format: catalogs/{catalog_name}/config.`) + + cmd.Use = "update-catalog-config NAME UPDATE_MASK" + cmd.Short = `Update config for a catalog.` + cmd.Long = `Update config for a catalog. + + Update the Data Classification configuration for a catalog. - The config must + already exist for the catalog. - Updates fields specified in the update_mask. + Use update_mask field to perform partial updates of the configuration. + + Arguments: + NAME: Resource name in the format: catalogs/{catalog_name}/config. + UPDATE_MASK: Field mask specifying which fields to update.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := updateCatalogConfigJson.Unmarshal(&updateCatalogConfigReq.CatalogConfig) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnostics(ctx, diags) + if err != nil { + return err + } + } + } + updateCatalogConfigReq.Name = args[0] + if args[1] != "" { + updateMaskArray := strings.Split(args[1], ",") + updateCatalogConfigReq.UpdateMask = *fieldmask.New(updateMaskArray) + } + + response, err := w.DataClassification.UpdateCatalogConfig(ctx, updateCatalogConfigReq) + 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 updateCatalogConfigOverrides { + fn(cmd, &updateCatalogConfigReq) + } + + return cmd +} + +// end service DataClassification diff --git a/cmd/workspace/feature-engineering/feature-engineering.go b/cmd/workspace/feature-engineering/feature-engineering.go index 26d6932db3..c0dc7e939a 100755 --- a/cmd/workspace/feature-engineering/feature-engineering.go +++ b/cmd/workspace/feature-engineering/feature-engineering.go @@ -75,7 +75,7 @@ func newCreateFeature() *cobra.Command { cmd.Flags().Var(&createFeatureJson, "json", `either inline JSON string or @path/to/file.json with request body`) cmd.Flags().StringVar(&createFeatureReq.Feature.Description, "description", createFeatureReq.Feature.Description, `The description of the feature.`) - cmd.Flags().StringVar(&createFeatureReq.Feature.FilterCondition, "filter-condition", createFeatureReq.Feature.FilterCondition, `The filter condition applied to the source data before aggregation.`) + cmd.Flags().StringVar(&createFeatureReq.Feature.FilterCondition, "filter-condition", createFeatureReq.Feature.FilterCondition, `Deprecated: Use DeltaTableSource.filter_condition or KafkaSource.filter_condition instead.`) // TODO: complex arg: lineage_context // TODO: complex arg: time_window @@ -88,7 +88,8 @@ func newCreateFeature() *cobra.Command { Arguments: FULL_NAME: The full three-part name (catalog, schema, name) of the feature. SOURCE: The data source of the feature. - INPUTS: The input columns from which the feature is computed. + INPUTS: Deprecated: Use AggregationFunction.inputs instead. Kept for backwards + compatibility. The input columns from which the feature is computed. FUNCTION: The function by which the feature is computed.` cmd.Annotations = make(map[string]string) @@ -295,6 +296,7 @@ func newCreateMaterializedFeature() *cobra.Command { cmd.Flags().Var(&createMaterializedFeatureJson, "json", `either inline JSON string or @path/to/file.json with request body`) cmd.Flags().StringVar(&createMaterializedFeatureReq.MaterializedFeature.CronSchedule, "cron-schedule", createMaterializedFeatureReq.MaterializedFeature.CronSchedule, `The quartz cron expression that defines the schedule of the materialization pipeline.`) + cmd.Flags().StringVar(&createMaterializedFeatureReq.MaterializedFeature.MaterializedFeatureId, "materialized-feature-id", createMaterializedFeatureReq.MaterializedFeature.MaterializedFeatureId, `Unique identifier for the materialized feature.`) // TODO: complex arg: offline_store_config // TODO: complex arg: online_store_config cmd.Flags().Var(&createMaterializedFeatureReq.MaterializedFeature.PipelineScheduleState, "pipeline-schedule-state", `The schedule state of the materialization pipeline. Supported values: [ACTIVE, PAUSED, SNAPSHOT]`) @@ -869,7 +871,7 @@ func newUpdateFeature() *cobra.Command { cmd.Flags().Var(&updateFeatureJson, "json", `either inline JSON string or @path/to/file.json with request body`) cmd.Flags().StringVar(&updateFeatureReq.Feature.Description, "description", updateFeatureReq.Feature.Description, `The description of the feature.`) - cmd.Flags().StringVar(&updateFeatureReq.Feature.FilterCondition, "filter-condition", updateFeatureReq.Feature.FilterCondition, `The filter condition applied to the source data before aggregation.`) + cmd.Flags().StringVar(&updateFeatureReq.Feature.FilterCondition, "filter-condition", updateFeatureReq.Feature.FilterCondition, `Deprecated: Use DeltaTableSource.filter_condition or KafkaSource.filter_condition instead.`) // TODO: complex arg: lineage_context // TODO: complex arg: time_window @@ -883,7 +885,8 @@ func newUpdateFeature() *cobra.Command { FULL_NAME: The full three-part name (catalog, schema, name) of the feature. UPDATE_MASK: The list of fields to update. SOURCE: The data source of the feature. - INPUTS: The input columns from which the feature is computed. + INPUTS: Deprecated: Use AggregationFunction.inputs instead. Kept for backwards + compatibility. The input columns from which the feature is computed. FUNCTION: The function by which the feature is computed.` cmd.Annotations = make(map[string]string) @@ -1092,6 +1095,7 @@ func newUpdateMaterializedFeature() *cobra.Command { cmd.Flags().Var(&updateMaterializedFeatureJson, "json", `either inline JSON string or @path/to/file.json with request body`) cmd.Flags().StringVar(&updateMaterializedFeatureReq.MaterializedFeature.CronSchedule, "cron-schedule", updateMaterializedFeatureReq.MaterializedFeature.CronSchedule, `The quartz cron expression that defines the schedule of the materialization pipeline.`) + cmd.Flags().StringVar(&updateMaterializedFeatureReq.MaterializedFeature.MaterializedFeatureId, "materialized-feature-id", updateMaterializedFeatureReq.MaterializedFeature.MaterializedFeatureId, `Unique identifier for the materialized feature.`) // TODO: complex arg: offline_store_config // TODO: complex arg: online_store_config cmd.Flags().Var(&updateMaterializedFeatureReq.MaterializedFeature.PipelineScheduleState, "pipeline-schedule-state", `The schedule state of the materialization pipeline. Supported values: [ACTIVE, PAUSED, SNAPSHOT]`) diff --git a/cmd/workspace/genie/genie.go b/cmd/workspace/genie/genie.go index a035e7b3c8..82f7773bb7 100755 --- a/cmd/workspace/genie/genie.go +++ b/cmd/workspace/genie/genie.go @@ -39,6 +39,11 @@ func New() *cobra.Command { cmd.AddCommand(newExecuteMessageAttachmentQuery()) cmd.AddCommand(newExecuteMessageQuery()) cmd.AddCommand(newGenerateDownloadFullQueryResult()) + cmd.AddCommand(newGenieCreateEvalRun()) + cmd.AddCommand(newGenieGetEvalResultDetails()) + cmd.AddCommand(newGenieGetEvalRun()) + cmd.AddCommand(newGenieListEvalResults()) + cmd.AddCommand(newGenieListEvalRuns()) cmd.AddCommand(newGetDownloadFullQueryResult()) cmd.AddCommand(newGetMessage()) cmd.AddCommand(newGetMessageAttachmentQueryResult()) @@ -587,6 +592,337 @@ func newGenerateDownloadFullQueryResult() *cobra.Command { return cmd } +// start genie-create-eval-run 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 genieCreateEvalRunOverrides []func( + *cobra.Command, + *dashboards.GenieCreateEvalRunRequest, +) + +func newGenieCreateEvalRun() *cobra.Command { + cmd := &cobra.Command{} + + var genieCreateEvalRunReq dashboards.GenieCreateEvalRunRequest + var genieCreateEvalRunJson flags.JsonFlag + + cmd.Flags().Var(&genieCreateEvalRunJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + // TODO: array: benchmark_question_ids + + cmd.Use = "genie-create-eval-run SPACE_ID" + cmd.Short = `Create eval run for benchmarks.` + cmd.Long = `Create eval run for benchmarks. + + Create and run evaluations for multiple benchmark questions in a Genie space. + + Arguments: + SPACE_ID: The ID associated with the Genie space where the evaluations will be + executed.` + + // 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(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 := genieCreateEvalRunJson.Unmarshal(&genieCreateEvalRunReq) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnostics(ctx, diags) + if err != nil { + return err + } + } + } + genieCreateEvalRunReq.SpaceId = args[0] + + response, err := w.Genie.GenieCreateEvalRun(ctx, genieCreateEvalRunReq) + 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 genieCreateEvalRunOverrides { + fn(cmd, &genieCreateEvalRunReq) + } + + return cmd +} + +// start genie-get-eval-result-details command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var genieGetEvalResultDetailsOverrides []func( + *cobra.Command, + *dashboards.GenieGetEvalResultDetailsRequest, +) + +func newGenieGetEvalResultDetails() *cobra.Command { + cmd := &cobra.Command{} + + var genieGetEvalResultDetailsReq dashboards.GenieGetEvalResultDetailsRequest + + cmd.Use = "genie-get-eval-result-details SPACE_ID EVAL_RUN_ID RESULT_ID" + cmd.Short = `Get benchmark evaluation result details.` + cmd.Long = `Get benchmark evaluation result details. + + Get details for evaluation results. + + Arguments: + SPACE_ID: The ID associated with the Genie space where the evaluation run is + located. + EVAL_RUN_ID: The unique identifier for the evaluation run. + RESULT_ID: The unique identifier for the evaluation result.` + + // 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) + + genieGetEvalResultDetailsReq.SpaceId = args[0] + genieGetEvalResultDetailsReq.EvalRunId = args[1] + genieGetEvalResultDetailsReq.ResultId = args[2] + + response, err := w.Genie.GenieGetEvalResultDetails(ctx, genieGetEvalResultDetailsReq) + 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 genieGetEvalResultDetailsOverrides { + fn(cmd, &genieGetEvalResultDetailsReq) + } + + return cmd +} + +// start genie-get-eval-run 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 genieGetEvalRunOverrides []func( + *cobra.Command, + *dashboards.GenieGetEvalRunRequest, +) + +func newGenieGetEvalRun() *cobra.Command { + cmd := &cobra.Command{} + + var genieGetEvalRunReq dashboards.GenieGetEvalRunRequest + + cmd.Use = "genie-get-eval-run SPACE_ID EVAL_RUN_ID" + cmd.Short = `Get benchmark evaluation run.` + cmd.Long = `Get benchmark evaluation run. + + Get evaluation run details. + + Arguments: + SPACE_ID: The ID associated with the Genie space where the evaluation run is + located. + EVAL_RUN_ID: ` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + 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) + + genieGetEvalRunReq.SpaceId = args[0] + genieGetEvalRunReq.EvalRunId = args[1] + + response, err := w.Genie.GenieGetEvalRun(ctx, genieGetEvalRunReq) + 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 genieGetEvalRunOverrides { + fn(cmd, &genieGetEvalRunReq) + } + + return cmd +} + +// start genie-list-eval-results 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 genieListEvalResultsOverrides []func( + *cobra.Command, + *dashboards.GenieListEvalResultsRequest, +) + +func newGenieListEvalResults() *cobra.Command { + cmd := &cobra.Command{} + + var genieListEvalResultsReq dashboards.GenieListEvalResultsRequest + + cmd.Flags().IntVar(&genieListEvalResultsReq.PageSize, "page-size", genieListEvalResultsReq.PageSize, `Maximum number of eval results to return per page.`) + cmd.Flags().StringVar(&genieListEvalResultsReq.PageToken, "page-token", genieListEvalResultsReq.PageToken, `Opaque token to retrieve the next page of results.`) + + cmd.Use = "genie-list-eval-results SPACE_ID EVAL_RUN_ID" + cmd.Short = `List benchmark evaluation results.` + cmd.Long = `List benchmark evaluation results. + + List evaluation results for a specific evaluation run. + + Arguments: + SPACE_ID: The ID associated with the Genie space where the evaluation run is + located. + EVAL_RUN_ID: The unique identifier for the evaluation run.` + + // 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) + + genieListEvalResultsReq.SpaceId = args[0] + genieListEvalResultsReq.EvalRunId = args[1] + + response, err := w.Genie.GenieListEvalResults(ctx, genieListEvalResultsReq) + 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 genieListEvalResultsOverrides { + fn(cmd, &genieListEvalResultsReq) + } + + return cmd +} + +// start genie-list-eval-runs 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 genieListEvalRunsOverrides []func( + *cobra.Command, + *dashboards.GenieListEvalRunsRequest, +) + +func newGenieListEvalRuns() *cobra.Command { + cmd := &cobra.Command{} + + var genieListEvalRunsReq dashboards.GenieListEvalRunsRequest + + cmd.Flags().IntVar(&genieListEvalRunsReq.PageSize, "page-size", genieListEvalRunsReq.PageSize, `Maximum number of evaluation runs to return per page.`) + cmd.Flags().StringVar(&genieListEvalRunsReq.PageToken, "page-token", genieListEvalRunsReq.PageToken, `Token to get the next page of results.`) + + cmd.Use = "genie-list-eval-runs SPACE_ID" + cmd.Short = `List all evaluation runs in the space.` + cmd.Long = `List all evaluation runs in the space. + + Lists all evaluation runs in a space. + + Arguments: + SPACE_ID: The ID associated with the Genie space where the evaluation run is + located.` + + // 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(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) + + genieListEvalRunsReq.SpaceId = args[0] + + response, err := w.Genie.GenieListEvalRuns(ctx, genieListEvalRunsReq) + 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 genieListEvalRunsOverrides { + fn(cmd, &genieListEvalRunsReq) + } + + return cmd +} + // start get-download-full-query-result command // Slice with functions to override default command behavior. diff --git a/cmd/workspace/groups.go b/cmd/workspace/groups.go index b4bdcc25ae..27dca16729 100644 --- a/cmd/workspace/groups.go +++ b/cmd/workspace/groups.go @@ -80,6 +80,10 @@ func Groups() []cobra.Group { ID: "qualitymonitor", Title: "Quality Monitor", }, + { + ID: "dataclassification", + Title: "Data Classification", + }, { ID: "dataquality", Title: "Data Quality Monitoring", diff --git a/cmd/workspace/knowledge-assistants/knowledge-assistants.go b/cmd/workspace/knowledge-assistants/knowledge-assistants.go new file mode 100755 index 0000000000..e9aa6cfd20 --- /dev/null +++ b/cmd/workspace/knowledge-assistants/knowledge-assistants.go @@ -0,0 +1,853 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package knowledge_assistants + +import ( + "fmt" + "strings" + + "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/common/types/fieldmask" + "github.com/databricks/databricks-sdk-go/service/knowledgeassistants" + "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: "knowledge-assistants", + Short: `Manage Knowledge Assistants and related resources.`, + Long: `Manage Knowledge Assistants and related resources.`, + GroupID: "agentbricks", + RunE: root.ReportUnknownSubcommand, + } + + // Add methods + cmd.AddCommand(newCreateKnowledgeAssistant()) + cmd.AddCommand(newCreateKnowledgeSource()) + cmd.AddCommand(newDeleteKnowledgeAssistant()) + cmd.AddCommand(newDeleteKnowledgeSource()) + cmd.AddCommand(newGetKnowledgeAssistant()) + cmd.AddCommand(newGetKnowledgeSource()) + cmd.AddCommand(newListKnowledgeAssistants()) + cmd.AddCommand(newListKnowledgeSources()) + cmd.AddCommand(newSyncKnowledgeSources()) + cmd.AddCommand(newUpdateKnowledgeAssistant()) + cmd.AddCommand(newUpdateKnowledgeSource()) + + // Apply optional overrides to this command. + for _, fn := range cmdOverrides { + fn(cmd) + } + + return cmd +} + +// start create-knowledge-assistant 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 createKnowledgeAssistantOverrides []func( + *cobra.Command, + *knowledgeassistants.CreateKnowledgeAssistantRequest, +) + +func newCreateKnowledgeAssistant() *cobra.Command { + cmd := &cobra.Command{} + + var createKnowledgeAssistantReq knowledgeassistants.CreateKnowledgeAssistantRequest + createKnowledgeAssistantReq.KnowledgeAssistant = knowledgeassistants.KnowledgeAssistant{} + var createKnowledgeAssistantJson flags.JsonFlag + + cmd.Flags().Var(&createKnowledgeAssistantJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&createKnowledgeAssistantReq.KnowledgeAssistant.Instructions, "instructions", createKnowledgeAssistantReq.KnowledgeAssistant.Instructions, `Additional global instructions on how the agent should generate answers.`) + cmd.Flags().StringVar(&createKnowledgeAssistantReq.KnowledgeAssistant.Name, "name", createKnowledgeAssistantReq.KnowledgeAssistant.Name, `The resource name of the Knowledge Assistant.`) + + cmd.Use = "create-knowledge-assistant DISPLAY_NAME DESCRIPTION" + cmd.Short = `Create a Knowledge Assistant.` + cmd.Long = `Create a Knowledge Assistant. + + Creates a Knowledge Assistant. + + Arguments: + DISPLAY_NAME: The display name of the Knowledge Assistant, unique at workspace level. + Required when creating a Knowledge Assistant. When updating a Knowledge + Assistant, optional unless included in update_mask. + DESCRIPTION: Description of what this agent can do (user-facing). Required when + creating a Knowledge Assistant. When updating a Knowledge Assistant, + optional unless included in update_mask.` + + 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 'display_name', 'description' in your JSON input") + } + return nil + } + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + diags := createKnowledgeAssistantJson.Unmarshal(&createKnowledgeAssistantReq.KnowledgeAssistant) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnostics(ctx, diags) + if err != nil { + return err + } + } + } + if !cmd.Flags().Changed("json") { + createKnowledgeAssistantReq.KnowledgeAssistant.DisplayName = args[0] + } + if !cmd.Flags().Changed("json") { + createKnowledgeAssistantReq.KnowledgeAssistant.Description = args[1] + } + + response, err := w.KnowledgeAssistants.CreateKnowledgeAssistant(ctx, createKnowledgeAssistantReq) + 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 createKnowledgeAssistantOverrides { + fn(cmd, &createKnowledgeAssistantReq) + } + + return cmd +} + +// start create-knowledge-source 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 createKnowledgeSourceOverrides []func( + *cobra.Command, + *knowledgeassistants.CreateKnowledgeSourceRequest, +) + +func newCreateKnowledgeSource() *cobra.Command { + cmd := &cobra.Command{} + + var createKnowledgeSourceReq knowledgeassistants.CreateKnowledgeSourceRequest + createKnowledgeSourceReq.KnowledgeSource = knowledgeassistants.KnowledgeSource{} + var createKnowledgeSourceJson flags.JsonFlag + + cmd.Flags().Var(&createKnowledgeSourceJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + // TODO: complex arg: file_table + // TODO: complex arg: files + // TODO: complex arg: index + cmd.Flags().StringVar(&createKnowledgeSourceReq.KnowledgeSource.Name, "name", createKnowledgeSourceReq.KnowledgeSource.Name, `Full resource name: knowledge-assistants/{knowledge_assistant_id}/knowledge-sources/{knowledge_source_id}.`) + + cmd.Use = "create-knowledge-source PARENT DISPLAY_NAME DESCRIPTION SOURCE_TYPE" + cmd.Short = `Create a Knowledge Source.` + cmd.Long = `Create a Knowledge Source. + + Creates a Knowledge Source under a Knowledge Assistant. + + Arguments: + PARENT: Parent resource where this source will be created. Format: + knowledge-assistants/{knowledge_assistant_id} + DISPLAY_NAME: Human-readable display name of the knowledge source. Required when + creating a Knowledge Source. When updating a Knowledge Source, optional + unless included in update_mask. + DESCRIPTION: Description of the knowledge source. Required when creating a Knowledge + Source. When updating a Knowledge Source, optional unless included in + update_mask. + SOURCE_TYPE: The type of the source: "index", "files", or "file_table". Required when + creating a Knowledge Source. When updating a Knowledge Source, this field + is ignored.` + + 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 PARENT as positional arguments. Provide 'display_name', 'description', 'source_type' 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 := createKnowledgeSourceJson.Unmarshal(&createKnowledgeSourceReq.KnowledgeSource) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnostics(ctx, diags) + if err != nil { + return err + } + } + } + createKnowledgeSourceReq.Parent = args[0] + if !cmd.Flags().Changed("json") { + createKnowledgeSourceReq.KnowledgeSource.DisplayName = args[1] + } + if !cmd.Flags().Changed("json") { + createKnowledgeSourceReq.KnowledgeSource.Description = args[2] + } + if !cmd.Flags().Changed("json") { + createKnowledgeSourceReq.KnowledgeSource.SourceType = args[3] + } + + response, err := w.KnowledgeAssistants.CreateKnowledgeSource(ctx, createKnowledgeSourceReq) + 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 createKnowledgeSourceOverrides { + fn(cmd, &createKnowledgeSourceReq) + } + + return cmd +} + +// start delete-knowledge-assistant 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 deleteKnowledgeAssistantOverrides []func( + *cobra.Command, + *knowledgeassistants.DeleteKnowledgeAssistantRequest, +) + +func newDeleteKnowledgeAssistant() *cobra.Command { + cmd := &cobra.Command{} + + var deleteKnowledgeAssistantReq knowledgeassistants.DeleteKnowledgeAssistantRequest + + cmd.Use = "delete-knowledge-assistant NAME" + cmd.Short = `Delete a Knowledge Assistant.` + cmd.Long = `Delete a Knowledge Assistant. + + Deletes a Knowledge Assistant. + + Arguments: + NAME: The resource name of the knowledge assistant to be deleted. Format: + knowledge-assistants/{knowledge_assistant_id}` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + deleteKnowledgeAssistantReq.Name = args[0] + + err = w.KnowledgeAssistants.DeleteKnowledgeAssistant(ctx, deleteKnowledgeAssistantReq) + 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 deleteKnowledgeAssistantOverrides { + fn(cmd, &deleteKnowledgeAssistantReq) + } + + return cmd +} + +// start delete-knowledge-source 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 deleteKnowledgeSourceOverrides []func( + *cobra.Command, + *knowledgeassistants.DeleteKnowledgeSourceRequest, +) + +func newDeleteKnowledgeSource() *cobra.Command { + cmd := &cobra.Command{} + + var deleteKnowledgeSourceReq knowledgeassistants.DeleteKnowledgeSourceRequest + + cmd.Use = "delete-knowledge-source NAME" + cmd.Short = `Delete a Knowledge Source.` + cmd.Long = `Delete a Knowledge Source. + + Deletes a Knowledge Source. + + Arguments: + NAME: The resource name of the Knowledge Source to delete. Format: + knowledge-assistants/{knowledge_assistant_id}/knowledge-sources/{knowledge_source_id}` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + deleteKnowledgeSourceReq.Name = args[0] + + err = w.KnowledgeAssistants.DeleteKnowledgeSource(ctx, deleteKnowledgeSourceReq) + 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 deleteKnowledgeSourceOverrides { + fn(cmd, &deleteKnowledgeSourceReq) + } + + return cmd +} + +// start get-knowledge-assistant 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 getKnowledgeAssistantOverrides []func( + *cobra.Command, + *knowledgeassistants.GetKnowledgeAssistantRequest, +) + +func newGetKnowledgeAssistant() *cobra.Command { + cmd := &cobra.Command{} + + var getKnowledgeAssistantReq knowledgeassistants.GetKnowledgeAssistantRequest + + cmd.Use = "get-knowledge-assistant NAME" + cmd.Short = `Get a Knowledge Assistant.` + cmd.Long = `Get a Knowledge Assistant. + + Gets a Knowledge Assistant. + + Arguments: + NAME: The resource name of the knowledge assistant. Format: + knowledge-assistants/{knowledge_assistant_id}` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + getKnowledgeAssistantReq.Name = args[0] + + response, err := w.KnowledgeAssistants.GetKnowledgeAssistant(ctx, getKnowledgeAssistantReq) + 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 getKnowledgeAssistantOverrides { + fn(cmd, &getKnowledgeAssistantReq) + } + + return cmd +} + +// start get-knowledge-source 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 getKnowledgeSourceOverrides []func( + *cobra.Command, + *knowledgeassistants.GetKnowledgeSourceRequest, +) + +func newGetKnowledgeSource() *cobra.Command { + cmd := &cobra.Command{} + + var getKnowledgeSourceReq knowledgeassistants.GetKnowledgeSourceRequest + + cmd.Use = "get-knowledge-source NAME" + cmd.Short = `Get a Knowledge Source.` + cmd.Long = `Get a Knowledge Source. + + Gets a Knowledge Source. + + Arguments: + NAME: The resource name of the Knowledge Source. Format: + knowledge-assistants/{knowledge_assistant_id}/knowledge-sources/{knowledge_source_id}` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + getKnowledgeSourceReq.Name = args[0] + + response, err := w.KnowledgeAssistants.GetKnowledgeSource(ctx, getKnowledgeSourceReq) + 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 getKnowledgeSourceOverrides { + fn(cmd, &getKnowledgeSourceReq) + } + + return cmd +} + +// start list-knowledge-assistants 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 listKnowledgeAssistantsOverrides []func( + *cobra.Command, + *knowledgeassistants.ListKnowledgeAssistantsRequest, +) + +func newListKnowledgeAssistants() *cobra.Command { + cmd := &cobra.Command{} + + var listKnowledgeAssistantsReq knowledgeassistants.ListKnowledgeAssistantsRequest + + cmd.Flags().IntVar(&listKnowledgeAssistantsReq.PageSize, "page-size", listKnowledgeAssistantsReq.PageSize, `The maximum number of knowledge assistants to return.`) + cmd.Flags().StringVar(&listKnowledgeAssistantsReq.PageToken, "page-token", listKnowledgeAssistantsReq.PageToken, `A page token, received from a previous ListKnowledgeAssistants call.`) + + cmd.Use = "list-knowledge-assistants" + cmd.Short = `List Knowledge Assistants.` + cmd.Long = `List Knowledge Assistants. + + List Knowledge Assistants` + + 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.KnowledgeAssistants.ListKnowledgeAssistants(ctx, listKnowledgeAssistantsReq) + 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 listKnowledgeAssistantsOverrides { + fn(cmd, &listKnowledgeAssistantsReq) + } + + return cmd +} + +// start list-knowledge-sources 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 listKnowledgeSourcesOverrides []func( + *cobra.Command, + *knowledgeassistants.ListKnowledgeSourcesRequest, +) + +func newListKnowledgeSources() *cobra.Command { + cmd := &cobra.Command{} + + var listKnowledgeSourcesReq knowledgeassistants.ListKnowledgeSourcesRequest + + cmd.Flags().IntVar(&listKnowledgeSourcesReq.PageSize, "page-size", listKnowledgeSourcesReq.PageSize, ``) + cmd.Flags().StringVar(&listKnowledgeSourcesReq.PageToken, "page-token", listKnowledgeSourcesReq.PageToken, ``) + + cmd.Use = "list-knowledge-sources PARENT" + cmd.Short = `List Knowledge Sources.` + cmd.Long = `List Knowledge Sources. + + Lists Knowledge Sources under a Knowledge Assistant. + + Arguments: + PARENT: Parent resource to list from. Format: + knowledge-assistants/{knowledge_assistant_id}` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + listKnowledgeSourcesReq.Parent = args[0] + + response := w.KnowledgeAssistants.ListKnowledgeSources(ctx, listKnowledgeSourcesReq) + 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 listKnowledgeSourcesOverrides { + fn(cmd, &listKnowledgeSourcesReq) + } + + return cmd +} + +// start sync-knowledge-sources 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 syncKnowledgeSourcesOverrides []func( + *cobra.Command, + *knowledgeassistants.SyncKnowledgeSourcesRequest, +) + +func newSyncKnowledgeSources() *cobra.Command { + cmd := &cobra.Command{} + + var syncKnowledgeSourcesReq knowledgeassistants.SyncKnowledgeSourcesRequest + + cmd.Use = "sync-knowledge-sources NAME" + cmd.Short = `Syncs all Knowledge Sources for a Knowledge Assistant.` + cmd.Long = `Syncs all Knowledge Sources for a Knowledge Assistant. + + Sync all non-index Knowledge Sources for a Knowledge Assistant (index sources + do not require sync) + + Arguments: + NAME: The resource name of the Knowledge Assistant. Format: + knowledge-assistants/{knowledge_assistant_id}` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := cmdctx.WorkspaceClient(ctx) + + syncKnowledgeSourcesReq.Name = args[0] + + err = w.KnowledgeAssistants.SyncKnowledgeSources(ctx, syncKnowledgeSourcesReq) + 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 syncKnowledgeSourcesOverrides { + fn(cmd, &syncKnowledgeSourcesReq) + } + + return cmd +} + +// start update-knowledge-assistant 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 updateKnowledgeAssistantOverrides []func( + *cobra.Command, + *knowledgeassistants.UpdateKnowledgeAssistantRequest, +) + +func newUpdateKnowledgeAssistant() *cobra.Command { + cmd := &cobra.Command{} + + var updateKnowledgeAssistantReq knowledgeassistants.UpdateKnowledgeAssistantRequest + updateKnowledgeAssistantReq.KnowledgeAssistant = knowledgeassistants.KnowledgeAssistant{} + var updateKnowledgeAssistantJson flags.JsonFlag + + cmd.Flags().Var(&updateKnowledgeAssistantJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&updateKnowledgeAssistantReq.KnowledgeAssistant.Instructions, "instructions", updateKnowledgeAssistantReq.KnowledgeAssistant.Instructions, `Additional global instructions on how the agent should generate answers.`) + cmd.Flags().StringVar(&updateKnowledgeAssistantReq.KnowledgeAssistant.Name, "name", updateKnowledgeAssistantReq.KnowledgeAssistant.Name, `The resource name of the Knowledge Assistant.`) + + cmd.Use = "update-knowledge-assistant NAME UPDATE_MASK DISPLAY_NAME DESCRIPTION" + cmd.Short = `Update a Knowledge Assistant.` + cmd.Long = `Update a Knowledge Assistant. + + Updates a Knowledge Assistant. + + Arguments: + NAME: The resource name of the Knowledge Assistant. Format: + knowledge-assistants/{knowledge_assistant_id} + UPDATE_MASK: Comma-delimited list of fields to update on the Knowledge Assistant. + Allowed values: display_name, description, instructions. Examples: - + display_name - description,instructions + DISPLAY_NAME: The display name of the Knowledge Assistant, unique at workspace level. + Required when creating a Knowledge Assistant. When updating a Knowledge + Assistant, optional unless included in update_mask. + DESCRIPTION: Description of what this agent can do (user-facing). Required when + creating a Knowledge Assistant. When updating a Knowledge Assistant, + optional unless included in update_mask.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + if cmd.Flags().Changed("json") { + err := root.ExactArgs(2)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, provide only NAME, UPDATE_MASK as positional arguments. Provide 'display_name', 'description' 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 := updateKnowledgeAssistantJson.Unmarshal(&updateKnowledgeAssistantReq.KnowledgeAssistant) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnostics(ctx, diags) + if err != nil { + return err + } + } + } + updateKnowledgeAssistantReq.Name = args[0] + if args[1] != "" { + updateMaskArray := strings.Split(args[1], ",") + updateKnowledgeAssistantReq.UpdateMask = *fieldmask.New(updateMaskArray) + } + if !cmd.Flags().Changed("json") { + updateKnowledgeAssistantReq.KnowledgeAssistant.DisplayName = args[2] + } + if !cmd.Flags().Changed("json") { + updateKnowledgeAssistantReq.KnowledgeAssistant.Description = args[3] + } + + response, err := w.KnowledgeAssistants.UpdateKnowledgeAssistant(ctx, updateKnowledgeAssistantReq) + 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 updateKnowledgeAssistantOverrides { + fn(cmd, &updateKnowledgeAssistantReq) + } + + return cmd +} + +// start update-knowledge-source 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 updateKnowledgeSourceOverrides []func( + *cobra.Command, + *knowledgeassistants.UpdateKnowledgeSourceRequest, +) + +func newUpdateKnowledgeSource() *cobra.Command { + cmd := &cobra.Command{} + + var updateKnowledgeSourceReq knowledgeassistants.UpdateKnowledgeSourceRequest + updateKnowledgeSourceReq.KnowledgeSource = knowledgeassistants.KnowledgeSource{} + var updateKnowledgeSourceJson flags.JsonFlag + + cmd.Flags().Var(&updateKnowledgeSourceJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + // TODO: complex arg: file_table + // TODO: complex arg: files + // TODO: complex arg: index + cmd.Flags().StringVar(&updateKnowledgeSourceReq.KnowledgeSource.Name, "name", updateKnowledgeSourceReq.KnowledgeSource.Name, `Full resource name: knowledge-assistants/{knowledge_assistant_id}/knowledge-sources/{knowledge_source_id}.`) + + cmd.Use = "update-knowledge-source NAME UPDATE_MASK DISPLAY_NAME DESCRIPTION SOURCE_TYPE" + cmd.Short = `Update a Knowledge Source.` + cmd.Long = `Update a Knowledge Source. + + Updates a Knowledge Source. + + Arguments: + NAME: The resource name of the Knowledge Source to update. Format: + knowledge-assistants/{knowledge_assistant_id}/knowledge-sources/{knowledge_source_id} + UPDATE_MASK: Comma-delimited list of fields to update on the Knowledge Source. Allowed + values: display_name, description. Examples: - display_name - + display_name,description + DISPLAY_NAME: Human-readable display name of the knowledge source. Required when + creating a Knowledge Source. When updating a Knowledge Source, optional + unless included in update_mask. + DESCRIPTION: Description of the knowledge source. Required when creating a Knowledge + Source. When updating a Knowledge Source, optional unless included in + update_mask. + SOURCE_TYPE: The type of the source: "index", "files", or "file_table". Required when + creating a Knowledge Source. When updating a Knowledge Source, this field + is ignored.` + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + if cmd.Flags().Changed("json") { + err := root.ExactArgs(2)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, provide only NAME, UPDATE_MASK as positional arguments. Provide 'display_name', 'description', 'source_type' 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 := updateKnowledgeSourceJson.Unmarshal(&updateKnowledgeSourceReq.KnowledgeSource) + if diags.HasError() { + return diags.Error() + } + if len(diags) > 0 { + err := cmdio.RenderDiagnostics(ctx, diags) + if err != nil { + return err + } + } + } + updateKnowledgeSourceReq.Name = args[0] + if args[1] != "" { + updateMaskArray := strings.Split(args[1], ",") + updateKnowledgeSourceReq.UpdateMask = *fieldmask.New(updateMaskArray) + } + if !cmd.Flags().Changed("json") { + updateKnowledgeSourceReq.KnowledgeSource.DisplayName = args[2] + } + if !cmd.Flags().Changed("json") { + updateKnowledgeSourceReq.KnowledgeSource.Description = args[3] + } + if !cmd.Flags().Changed("json") { + updateKnowledgeSourceReq.KnowledgeSource.SourceType = args[4] + } + + response, err := w.KnowledgeAssistants.UpdateKnowledgeSource(ctx, updateKnowledgeSourceReq) + 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 updateKnowledgeSourceOverrides { + fn(cmd, &updateKnowledgeSourceReq) + } + + return cmd +} + +// end service KnowledgeAssistants diff --git a/cmd/workspace/permissions/permissions.go b/cmd/workspace/permissions/permissions.go index 5af0432886..9b644776aa 100755 --- a/cmd/workspace/permissions/permissions.go +++ b/cmd/workspace/permissions/permissions.go @@ -92,9 +92,9 @@ func newGet() *cobra.Command { Arguments: REQUEST_OBJECT_TYPE: The type of the request object. Can be one of the following: alerts, alertsv2, authorization, clusters, cluster-policies, dashboards, - dbsql-dashboards, directories, experiments, files, genie, instance-pools, - jobs, notebooks, pipelines, queries, registered-models, repos, - serving-endpoints, or warehouses. + database-projects, dbsql-dashboards, directories, experiments, files, + genie, instance-pools, jobs, notebooks, pipelines, queries, + registered-models, repos, serving-endpoints, or warehouses. REQUEST_OBJECT_ID: The id of the request object.` cmd.Annotations = make(map[string]string) @@ -154,9 +154,9 @@ func newGetPermissionLevels() *cobra.Command { Arguments: REQUEST_OBJECT_TYPE: The type of the request object. Can be one of the following: alerts, alertsv2, authorization, clusters, cluster-policies, dashboards, - dbsql-dashboards, directories, experiments, files, genie, instance-pools, - jobs, notebooks, pipelines, queries, registered-models, repos, - serving-endpoints, or warehouses. + database-projects, dbsql-dashboards, directories, experiments, files, + genie, instance-pools, jobs, notebooks, pipelines, queries, + registered-models, repos, serving-endpoints, or warehouses. REQUEST_OBJECT_ID: ` cmd.Annotations = make(map[string]string) @@ -223,9 +223,9 @@ func newSet() *cobra.Command { Arguments: REQUEST_OBJECT_TYPE: The type of the request object. Can be one of the following: alerts, alertsv2, authorization, clusters, cluster-policies, dashboards, - dbsql-dashboards, directories, experiments, files, genie, instance-pools, - jobs, notebooks, pipelines, queries, registered-models, repos, - serving-endpoints, or warehouses. + database-projects, dbsql-dashboards, directories, experiments, files, + genie, instance-pools, jobs, notebooks, pipelines, queries, + registered-models, repos, serving-endpoints, or warehouses. REQUEST_OBJECT_ID: The id of the request object.` cmd.Annotations = make(map[string]string) @@ -303,9 +303,9 @@ func newUpdate() *cobra.Command { Arguments: REQUEST_OBJECT_TYPE: The type of the request object. Can be one of the following: alerts, alertsv2, authorization, clusters, cluster-policies, dashboards, - dbsql-dashboards, directories, experiments, files, genie, instance-pools, - jobs, notebooks, pipelines, queries, registered-models, repos, - serving-endpoints, or warehouses. + database-projects, dbsql-dashboards, directories, experiments, files, + genie, instance-pools, jobs, notebooks, pipelines, queries, + registered-models, repos, serving-endpoints, or warehouses. REQUEST_OBJECT_ID: The id of the request object.` cmd.Annotations = make(map[string]string) diff --git a/cmd/workspace/workspace-entity-tag-assignments/workspace-entity-tag-assignments.go b/cmd/workspace/workspace-entity-tag-assignments/workspace-entity-tag-assignments.go index d5f0c8f94d..e15733be8b 100755 --- a/cmd/workspace/workspace-entity-tag-assignments/workspace-entity-tag-assignments.go +++ b/cmd/workspace/workspace-entity-tag-assignments/workspace-entity-tag-assignments.go @@ -69,7 +69,7 @@ func newCreateTagAssignment() *cobra.Command { Arguments: ENTITY_TYPE: The type of entity to which the tag is assigned. Allowed values are apps, - dashboards, geniespaces + dashboards, geniespaces, notebooks ENTITY_ID: The identifier of the entity to which the tag is assigned. For apps, the entity_id is the app name TAG_KEY: The key of the tag. The characters , . : / - = and leading/trailing spaces @@ -157,7 +157,7 @@ func newDeleteTagAssignment() *cobra.Command { Arguments: ENTITY_TYPE: The type of entity to which the tag is assigned. Allowed values are apps, - dashboards, geniespaces + dashboards, geniespaces, notebooks ENTITY_ID: The identifier of the entity to which the tag is assigned. For apps, the entity_id is the app name TAG_KEY: The key of the tag. The characters , . : / - = and leading/trailing spaces @@ -220,7 +220,7 @@ func newGetTagAssignment() *cobra.Command { Arguments: ENTITY_TYPE: The type of entity to which the tag is assigned. Allowed values are apps, - dashboards, geniespaces + dashboards, geniespaces, notebooks ENTITY_ID: The identifier of the entity to which the tag is assigned. For apps, the entity_id is the app name TAG_KEY: The key of the tag. The characters , . : / - = and leading/trailing spaces @@ -286,7 +286,7 @@ func newListTagAssignments() *cobra.Command { Arguments: ENTITY_TYPE: The type of entity to which the tag is assigned. Allowed values are apps, - dashboards, geniespaces + dashboards, geniespaces, notebooks ENTITY_ID: The identifier of the entity to which the tag is assigned. For apps, the entity_id is the app name` @@ -349,7 +349,7 @@ func newUpdateTagAssignment() *cobra.Command { Arguments: ENTITY_TYPE: The type of entity to which the tag is assigned. Allowed values are apps, - dashboards, geniespaces + dashboards, geniespaces, notebooks ENTITY_ID: The identifier of the entity to which the tag is assigned. For apps, the entity_id is the app name TAG_KEY: The key of the tag. The characters , . : / - = and leading/trailing spaces diff --git a/go.mod b/go.mod index aabc6aa959..7f633c0c72 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/charmbracelet/bubbletea v1.3.10 // MIT github.com/charmbracelet/huh v1.0.0 github.com/charmbracelet/lipgloss v1.1.0 // MIT - github.com/databricks/databricks-sdk-go v0.117.0 // Apache 2.0 + github.com/databricks/databricks-sdk-go v0.119.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 6a08027b20..3cb5d3228f 100644 --- a/go.sum +++ b/go.sum @@ -75,8 +75,8 @@ github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s= github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE= 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.117.0 h1:CJNFcQIkHgPMVJTSeiQoHftl0cIIvG4bOMpJSRssXpE= -github.com/databricks/databricks-sdk-go v0.117.0/go.mod h1:hWoHnHbNLjPKiTm5K/7bcIv3J3Pkgo5x9pPzh8K3RVE= +github.com/databricks/databricks-sdk-go v0.119.0 h1:Fot5T4bBGxfuFHII0xLPXuzkBmALWiJeUBeuXQX2Pcw= +github.com/databricks/databricks-sdk-go v0.119.0/go.mod h1:hWoHnHbNLjPKiTm5K/7bcIv3J3Pkgo5x9pPzh8K3RVE= 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= From 63fcd7edda0301c0ae0b085bdc00f07b3b9a4ed6 Mon Sep 17 00:00:00 2001 From: Pawel Kosiec Date: Tue, 10 Mar 2026 17:26:06 +0100 Subject: [PATCH 2/2] Run `wsfix`, fix tests, add changelog entry --- NEXT_CHANGELOG.md | 2 +- acceptance/help/output.txt | 3 +++ .../data-classification.go | 10 ++++----- .../knowledge-assistants.go | 22 +++++++++---------- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index 37b08bcf3c..d2f703a314 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -8,6 +8,6 @@ * Modify grants to use SDK types ([#4666](https://github.com/databricks/cli/pull/4666)) ### Dependency updates -- Bump databricks-sdk-go from v0.112.0 to v0.119.0. ([#4631](https://github.com/databricks/cli/pull/4631)) +* Bump databricks-sdk-go from v0.112.0 to v0.119.0 ([#4631](https://github.com/databricks/cli/pull/4631), [#4695](https://github.com/databricks/cli/pull/4695)) ### API Changes diff --git a/acceptance/help/output.txt b/acceptance/help/output.txt index fa9a1bdc19..19b491dd57 100644 --- a/acceptance/help/output.txt +++ b/acceptance/help/output.txt @@ -145,6 +145,9 @@ Database Instances database Database Instances provide access to a database via REST API or direct SQL. psql Connect to a Lakebase Postgres database +Agent Bricks + knowledge-assistants Manage Knowledge Assistants and related resources. + Tags tag-policies The Tag Policy API allows you to manage policies for governed tags in Databricks. workspace-entity-tag-assignments Manage tag assignments on workspace-scoped objects. diff --git a/cmd/workspace/data-classification/data-classification.go b/cmd/workspace/data-classification/data-classification.go index 3403a7772c..29056a9bc8 100755 --- a/cmd/workspace/data-classification/data-classification.go +++ b/cmd/workspace/data-classification/data-classification.go @@ -72,9 +72,9 @@ func newCreateCatalogConfig() *cobra.Command { cmd.Use = "create-catalog-config PARENT" cmd.Short = `Create config for a catalog.` cmd.Long = `Create config for a catalog. - + Create Data Classification configuration for a catalog. - + Creates a new config resource, which enables Data Classification for the specified catalog. - The config must not already exist for the catalog. @@ -143,7 +143,7 @@ func newDeleteCatalogConfig() *cobra.Command { cmd.Use = "delete-catalog-config NAME" cmd.Short = `Delete config for a catalog.` cmd.Long = `Delete config for a catalog. - + Delete Data Classification configuration for a catalog. Arguments: @@ -199,7 +199,7 @@ func newGetCatalogConfig() *cobra.Command { cmd.Use = "get-catalog-config NAME" cmd.Short = `Get config for a catalog.` cmd.Long = `Get config for a catalog. - + Get the Data Classification configuration for a catalog. Arguments: @@ -263,7 +263,7 @@ func newUpdateCatalogConfig() *cobra.Command { cmd.Use = "update-catalog-config NAME UPDATE_MASK" cmd.Short = `Update config for a catalog.` cmd.Long = `Update config for a catalog. - + Update the Data Classification configuration for a catalog. - The config must already exist for the catalog. - Updates fields specified in the update_mask. Use update_mask field to perform partial updates of the configuration. diff --git a/cmd/workspace/knowledge-assistants/knowledge-assistants.go b/cmd/workspace/knowledge-assistants/knowledge-assistants.go index e9aa6cfd20..a23c0fa88e 100755 --- a/cmd/workspace/knowledge-assistants/knowledge-assistants.go +++ b/cmd/workspace/knowledge-assistants/knowledge-assistants.go @@ -73,7 +73,7 @@ func newCreateKnowledgeAssistant() *cobra.Command { cmd.Use = "create-knowledge-assistant DISPLAY_NAME DESCRIPTION" cmd.Short = `Create a Knowledge Assistant.` cmd.Long = `Create a Knowledge Assistant. - + Creates a Knowledge Assistant. Arguments: @@ -167,7 +167,7 @@ func newCreateKnowledgeSource() *cobra.Command { cmd.Use = "create-knowledge-source PARENT DISPLAY_NAME DESCRIPTION SOURCE_TYPE" cmd.Short = `Create a Knowledge Source.` cmd.Long = `Create a Knowledge Source. - + Creates a Knowledge Source under a Knowledge Assistant. Arguments: @@ -261,7 +261,7 @@ func newDeleteKnowledgeAssistant() *cobra.Command { cmd.Use = "delete-knowledge-assistant NAME" cmd.Short = `Delete a Knowledge Assistant.` cmd.Long = `Delete a Knowledge Assistant. - + Deletes a Knowledge Assistant. Arguments: @@ -318,7 +318,7 @@ func newDeleteKnowledgeSource() *cobra.Command { cmd.Use = "delete-knowledge-source NAME" cmd.Short = `Delete a Knowledge Source.` cmd.Long = `Delete a Knowledge Source. - + Deletes a Knowledge Source. Arguments: @@ -375,7 +375,7 @@ func newGetKnowledgeAssistant() *cobra.Command { cmd.Use = "get-knowledge-assistant NAME" cmd.Short = `Get a Knowledge Assistant.` cmd.Long = `Get a Knowledge Assistant. - + Gets a Knowledge Assistant. Arguments: @@ -432,7 +432,7 @@ func newGetKnowledgeSource() *cobra.Command { cmd.Use = "get-knowledge-source NAME" cmd.Short = `Get a Knowledge Source.` cmd.Long = `Get a Knowledge Source. - + Gets a Knowledge Source. Arguments: @@ -492,7 +492,7 @@ func newListKnowledgeAssistants() *cobra.Command { cmd.Use = "list-knowledge-assistants" cmd.Short = `List Knowledge Assistants.` cmd.Long = `List Knowledge Assistants. - + List Knowledge Assistants` cmd.Annotations = make(map[string]string) @@ -543,7 +543,7 @@ func newListKnowledgeSources() *cobra.Command { cmd.Use = "list-knowledge-sources PARENT" cmd.Short = `List Knowledge Sources.` cmd.Long = `List Knowledge Sources. - + Lists Knowledge Sources under a Knowledge Assistant. Arguments: @@ -597,7 +597,7 @@ func newSyncKnowledgeSources() *cobra.Command { cmd.Use = "sync-knowledge-sources NAME" cmd.Short = `Syncs all Knowledge Sources for a Knowledge Assistant.` cmd.Long = `Syncs all Knowledge Sources for a Knowledge Assistant. - + Sync all non-index Knowledge Sources for a Knowledge Assistant (index sources do not require sync) @@ -662,7 +662,7 @@ func newUpdateKnowledgeAssistant() *cobra.Command { cmd.Use = "update-knowledge-assistant NAME UPDATE_MASK DISPLAY_NAME DESCRIPTION" cmd.Short = `Update a Knowledge Assistant.` cmd.Long = `Update a Knowledge Assistant. - + Updates a Knowledge Assistant. Arguments: @@ -766,7 +766,7 @@ func newUpdateKnowledgeSource() *cobra.Command { cmd.Use = "update-knowledge-source NAME UPDATE_MASK DISPLAY_NAME DESCRIPTION SOURCE_TYPE" cmd.Short = `Update a Knowledge Source.` cmd.Long = `Update a Knowledge Source. - + Updates a Knowledge Source. Arguments: